From 1ae5f787d06982ba1e51f1a84db20687e33bdf0b Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Sun, 21 Jul 2024 11:07:02 +0300 Subject: [PATCH] replace dots with dashes when renaming VMs Signed-off-by: Arik Hadas --- pkg/controller/plan/vm_name_handler.go | 2 +- pkg/controller/plan/vm_name_handler_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/controller/plan/vm_name_handler.go b/pkg/controller/plan/vm_name_handler.go index 1e7871ced..c9904cd8e 100644 --- a/pkg/controller/plan/vm_name_handler.go +++ b/pkg/controller/plan/vm_name_handler.go @@ -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) diff --git a/pkg/controller/plan/vm_name_handler_test.go b/pkg/controller/plan/vm_name_handler_test.go index 19c1d7171..16b6dca42 100644 --- a/pkg/controller/plan/vm_name_handler_test.go +++ b/pkg/controller/plan/vm_name_handler_test.go @@ -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