File tree Expand file tree Collapse file tree 2 files changed +5
-17
lines changed
src/uds/services/OpenShift Expand file tree Collapse file tree 2 files changed +5
-17
lines changed Original file line number Diff line number Diff 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 ]
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments