Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "_" in hostname #354

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docker/web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python3 -m pipenv install --dev

# Wait for database to be available before running migrations
until pg_isready -h "$POSTGRES_HOST" -U "$POSTGRES_USER" &> /dev/null; do
echo "Waiting for database to be ready ..."
echo "Waiting for database to be ready on ${POSTGRES_HOST} ..."
sleep 5
done

Expand Down
2 changes: 1 addition & 1 deletion serveradmin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ CREATE TABLE public.server (
hostname character varying(254) NOT NULL,
intern_ip inet,
servertype_id character varying(32) NOT NULL,
CONSTRAINT server_hostname_check CHECK (((hostname)::text ~ '\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z'::text))
CONSTRAINT server_hostname_check CHECK (((hostname)::text ~ '\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z'::text))
);


Expand Down
34 changes: 34 additions & 0 deletions serveradmin/serverdb/migrations/0018_alter_server_hostname.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.23 on 2024-01-04 08:23

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('serverdb', '0017_inet_family_choice'),
]

operations = [
migrations.AlterField(
model_name='server',
name='hostname',
field=models.CharField(max_length=254, unique=True, validators=[django.core.validators.RegexValidator('\\A(\\*\\.)?([a-z0-9_]+(\\.|-+))*[a-z0-9]+\\Z', 'Invalid hostname')]),
),
migrations.RunSQL(
sql=(
"ALTER TABLE server "
"DROP CONSTRAINT server_hostname_check, "
"ADD CONSTRAINT server_hostname_check "
"CHECK (hostname::text ~ '\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z'::text);"
),
reverse_sql=(
"ALTER TABLE server "
"DROP CONSTRAINT server_hostname_check, "
"ADD CONSTRAINT server_hostname_check "
"CHECK (hostname::text ~ '\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z'::text);"
)
),
]

2 changes: 1 addition & 1 deletion serveradmin/serverdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

HOSTNAME_VALIDATORS = [
RegexValidator(
r'\A(\*\.)?([a-z0-9]+(\.|-+))*[a-z0-9]+\Z', 'Invalid hostname'
r'\A(\*\.)?([a-z0-9_]+(\.|-+))*[a-z0-9]+\Z', 'Invalid hostname'
),
]

Expand Down
Loading