Skip to content

Commit 584ebe2

Browse files
committed
Merge branch 'master' of github.com:/VirtualCable/openuds
2 parents 7b28963 + d19086e commit 584ebe2

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

server/src/uds/services/OpenShift/provider.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,6 @@ def test(
125125
# Utility
126126
def sanitized_name(self, name: str) -> str:
127127
"""
128-
Sanitizes the VM name to comply with RFC 1123:
129-
- Converts to lowercase
130-
- Replaces any character not in [a-z0-9.-] with '-'
131-
- Collapses multiple '-' into one
132-
- Removes leading/trailing non-alphanumeric characters
133-
- Limits length to 63 characters
128+
OpenShift only allows machine names with [a-zA-Z0-9_-]
134129
"""
135-
name = name.lower()
136-
# Replace any character not allowed with '-'
137-
name = re.sub(r'[^a-z0-9.-]', '-', name)
138-
# Collapse multiple '-' into one
139-
name = re.sub(r'-{2,}', '-', name)
140-
# Remove leading/trailing non-alphanumeric characters
141-
name = re.sub(r'^[^a-z0-9]+|[^a-z0-9]+$', '', name)
142-
return name[:63]
130+
return re.sub(r'[^a-zA-Z0-9-]', '-', name).lower()[:63]

server/tests/services/openshift/test_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def test_sanitized_name(self) -> None:
134134
test_cases = [
135135
('Test-VM-1', 'test-vm-1'),
136136
('Test_VM@2', 'test-vm-2'),
137-
('My Test VM!!!', 'my-test-vm'),
138-
('Test !!! this is', 'test-this-is'),
139-
('UDS-Pub-Hello World!!--2025065122-v1', 'uds-pub-hello-world-2025065122-v1'),
137+
('My Test VM!!!', 'my-test-vm---'),
138+
('Test !!! this is', 'test-----this-is'),
139+
('UDS-Pub-Hello World!!--2025065122-v1', 'uds-pub-hello-world----2025065122-v1'),
140140
('a' * 100, 'a' * 63), # Test truncation
141141
]
142142
for input_name, expected in test_cases:

0 commit comments

Comments
 (0)