diff --git a/internal/service/templategenerator/templategenerator.go b/internal/service/templategenerator/templategenerator.go index 08e06f1..b85510b 100644 --- a/internal/service/templategenerator/templategenerator.go +++ b/internal/service/templategenerator/templategenerator.go @@ -133,7 +133,7 @@ func (s *Service) GenerateModuleTemplate( shortName := trimShortNameFromRef(ref) labels[shared.ModuleName] = shortName if moduleConfig.ResourceName == "" { - moduleConfig.ResourceName = shortName + "-" + moduleConfig.Channel + moduleConfig.ResourceName = shortName + "-" + moduleConfig.Version } moduleTemplate, err := template.New("moduleTemplate").Funcs(template.FuncMap{ diff --git a/tests/e2e/create/create_test.go b/tests/e2e/create/create_test.go index 74e888d..f63d599 100644 --- a/tests/e2e/create/create_test.go +++ b/tests/e2e/create/create_test.go @@ -10,7 +10,7 @@ import ( "ocm.software/ocm/api/ocm" "ocm.software/ocm/api/ocm/compdesc" ocmv1 "ocm.software/ocm/api/ocm/compdesc/meta/v1" - "ocm.software/ocm/api/ocm/compdesc/versions/v2" + v2 "ocm.software/ocm/api/ocm/compdesc/versions/v2" "ocm.software/ocm/api/ocm/extensions/accessmethods/github" "ocm.software/ocm/api/ocm/extensions/accessmethods/localblob" "ocm.software/ocm/api/ocm/extensions/accessmethods/ociartifact" @@ -218,6 +218,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { Expect(descriptor).ToNot(BeNil()) Expect(descriptor.SchemaVersion()).To(Equal(v2.SchemaVersion)) + Expect(template.Name).To(Equal("template-operator-1.0.0")) + By("And annotations should be correct") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.0")) @@ -303,6 +305,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.1")) + By("And new annotation should be correctly added") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.1")) @@ -337,6 +341,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.2")) + By("And annotation should have correct version") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.2")) @@ -384,6 +390,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.3")) + By("And descriptor.component.resources should be correct") Expect(descriptor.Resources).To(HaveLen(2)) resource := descriptor.Resources[0] @@ -459,6 +467,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.4")) + By("And annotation should have correct version") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.4")) @@ -490,6 +500,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.5")) + By("And annotation should have correct version") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.5")) @@ -528,6 +540,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.6")) + By("And annotation should have correct version") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.6")) @@ -542,14 +556,13 @@ var _ = Describe("Test 'create' command", Ordered, func() { Expect(manager.Kind).To(Equal("Deployment")) }) }) - - + Context("Given 'modulectl create' command", func() { var cmd createCmd It("When invoked with valid module-config containing associatedResources list", func() { cmd = createCmd{ moduleConfigFile: withAssociatedResourcesConfig, - registry: ociRegistry, + registry: ociRegistry, insecure: true, output: templateOutputPath, } @@ -566,6 +579,8 @@ var _ = Describe("Test 'create' command", Ordered, func() { descriptor := getDescriptor(template) Expect(descriptor).ToNot(BeNil()) + Expect(template.Name).To(Equal("template-operator-1.0.7")) + By("And annotation should have correct version") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.7"))