diff --git a/internal/nmc/labels.go b/internal/nmc/labels.go index a8121721f..9fcbfd9c4 100644 --- a/internal/nmc/labels.go +++ b/internal/nmc/labels.go @@ -6,8 +6,8 @@ import ( ) var ( - reConfiguredLabel = regexp.MustCompile(`^beta\.kmm\.node\.kubernetes\.io/([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)\.module-configured$`) - reInUseLabel = regexp.MustCompile(`^beta\.kmm\.node\.kubernetes\.io/([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)\.module-in-use$`) + reConfiguredLabel = regexp.MustCompile(`^beta\.kmm\.node\.kubernetes\.io/([a-zA-Z0-9-]+)\.([a-zA-Z0-9-\.]+)\.module-configured$`) + reInUseLabel = regexp.MustCompile(`^beta\.kmm\.node\.kubernetes\.io/([a-zA-Z0-9-]+)\.([a-zA-Z0-9-\.]+)\.module-in-use$`) ) func IsModuleConfiguredLabel(s string) (bool, string, string) { diff --git a/internal/nmc/labels_test.go b/internal/nmc/labels_test.go index aeed88a40..7c9f1e1a9 100644 --- a/internal/nmc/labels_test.go +++ b/internal/nmc/labels_test.go @@ -14,6 +14,15 @@ var _ = Describe("ModuleConfiguredLabel", func() { Equal("beta.kmm.node.kubernetes.io/a.b.module-configured"), ) }) + + It("should work as expected with a dot in the name", func() { + + Expect( + ModuleConfiguredLabel("a", "b.1"), + ).To( + Equal("beta.kmm.node.kubernetes.io/a.b.1.module-configured"), + ) + }) }) var _ = Describe("ModuleInUseLabel", func() { @@ -25,6 +34,15 @@ var _ = Describe("ModuleInUseLabel", func() { Equal("beta.kmm.node.kubernetes.io/a.b.module-in-use"), ) }) + + It("should work as expected with a dot in the name", func() { + + Expect( + ModuleInUseLabel("a", "b.1"), + ).To( + Equal("beta.kmm.node.kubernetes.io/a.b.1.module-in-use"), + ) + }) }) var _ = Describe("IsModuleConfiguredLabel", func() { @@ -47,6 +65,7 @@ var _ = Describe("IsModuleConfiguredLabel", func() { Entry(nil, "beta.kmm.node.kubernetes.io/..module-configured", false, "", ""), Entry(nil, "beta.kmm.node.kubernetes.io/a123.b456.module-configured", true, "a123", "b456"), Entry(nil, "beta.kmm.node.kubernetes.io/with-hypen.withouthypen.module-configured", true, "with-hypen", "withouthypen"), + Entry(nil, "beta.kmm.node.kubernetes.io/my-namespace.my-name.stil-my-name.module-configured", true, "my-namespace", "my-name.stil-my-name"), ) }) @@ -70,5 +89,6 @@ var _ = Describe("IsModuleInUseLabel", func() { Entry(nil, "beta.kmm.node.kubernetes.io/..module-in-use", false, "", ""), Entry(nil, "beta.kmm.node.kubernetes.io/a123.b456.module-in-use", true, "a123", "b456"), Entry(nil, "beta.kmm.node.kubernetes.io/with-hypen.withouthypen.module-in-use", true, "with-hypen", "withouthypen"), + Entry(nil, "beta.kmm.node.kubernetes.io/my-namespace.my-name.stil-my-name.module-in-use", true, "my-namespace", "my-name.stil-my-name"), ) })