Skip to content

Commit

Permalink
replace dots with dashes when renaming VMs
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Jul 23, 2024
1 parent 66d8d13 commit 95fc619
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/plan/vm_name_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r *KubeVirt) changeVmNameDNS1123(vmName string, vmNamespace string) (gener

// changes VM name to match DNS1123 RFC convention.
func changeVmName(currName string) string {
var underscoreExcluded = regexp.MustCompile("[_]")
var underscoreExcluded = regexp.MustCompile("[_.]")
var nameExcludeChars = regexp.MustCompile("[^a-z0-9-]")

newName := strings.ToLower(currName)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/plan/vm_name_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ func TestVmNameHandler(t *testing.T) {
g := gomega.NewGomegaWithT(t)

//Test all cases in name adjustments
originalVmName := "----------------Vm!@#$%^&*()_+-Name/.,';[]-CorREct-<>123----------------------"
newVmName := "vm--name-correct-123"
originalVmName := "----------------Vm!@#$%^&*()_+-Name/.is,';[]-CorREct-<>123----------------------"
newVmName := "vm--name-is-correct-123"
g.Expect(changeVmName(originalVmName)).To(gomega.Equal(newVmName))

//Test the case that the VM name is empty after all removals
Expand Down

0 comments on commit 95fc619

Please sign in to comment.