From 55f32185055f36a2523c2e154218f1093b49961b Mon Sep 17 00:00:00 2001 From: Amritanshu Sikdar Date: Wed, 23 Oct 2024 16:35:15 +0200 Subject: [PATCH 1/4] update metadata name ending to version --- internal/service/templategenerator/templategenerator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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{ From 50bb905c9e6766b1486033bec8b6a09fe119bd7f Mon Sep 17 00:00:00 2001 From: Amritanshu Sikdar Date: Wed, 23 Oct 2024 16:59:11 +0200 Subject: [PATCH 2/4] adjust e2e test accordingly --- tests/e2e/create/create_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/e2e/create/create_test.go b/tests/e2e/create/create_test.go index 74e888d..d6f1a9e 100644 --- a/tests/e2e/create/create_test.go +++ b/tests/e2e/create/create_test.go @@ -5,12 +5,13 @@ package create_test import ( "io/fs" "os" + "strings" "k8s.io/apimachinery/pkg/util/yaml" "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 +219,10 @@ var _ = Describe("Test 'create' command", Ordered, func() { Expect(descriptor).ToNot(BeNil()) Expect(descriptor.SchemaVersion()).To(Equal(v2.SchemaVersion)) + descriptorSplit := strings.Split(descriptor.Name, "/") + descriptorName := descriptorSplit[len(descriptorSplit)-1] + Expect(template.Name).To(Equal(descriptorName + "-" + descriptor.Version)) + By("And annotations should be correct") annotations := template.Annotations Expect(annotations[shared.ModuleVersionAnnotation]).To(Equal("1.0.0")) From e7ba239f1868b5aa3a0cf71bb63b0a10d8f16c75 Mon Sep 17 00:00:00 2001 From: Amritanshu Sikdar Date: Wed, 23 Oct 2024 20:55:35 +0200 Subject: [PATCH 3/4] fix import --- tests/e2e/create/create_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/create/create_test.go b/tests/e2e/create/create_test.go index d6f1a9e..7402208 100644 --- a/tests/e2e/create/create_test.go +++ b/tests/e2e/create/create_test.go @@ -11,7 +11,7 @@ import ( "ocm.software/ocm/api/ocm" "ocm.software/ocm/api/ocm/compdesc" ocmv1 "ocm.software/ocm/api/ocm/compdesc/meta/v1" - v2 "ocm.software/ocm/api/ocm/compdesc/versions/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" From f033ca31c9a36461e55912d39958f49d09a19c6f Mon Sep 17 00:00:00 2001 From: Amritanshu Sikdar Date: Mon, 28 Oct 2024 17:09:52 +0100 Subject: [PATCH 4/4] improve tests --- tests/e2e/create/create_test.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/e2e/create/create_test.go b/tests/e2e/create/create_test.go index 7402208..f63d599 100644 --- a/tests/e2e/create/create_test.go +++ b/tests/e2e/create/create_test.go @@ -5,13 +5,12 @@ package create_test import ( "io/fs" "os" - "strings" "k8s.io/apimachinery/pkg/util/yaml" "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" @@ -219,9 +218,7 @@ var _ = Describe("Test 'create' command", Ordered, func() { Expect(descriptor).ToNot(BeNil()) Expect(descriptor.SchemaVersion()).To(Equal(v2.SchemaVersion)) - descriptorSplit := strings.Split(descriptor.Name, "/") - descriptorName := descriptorSplit[len(descriptorSplit)-1] - Expect(template.Name).To(Equal(descriptorName + "-" + descriptor.Version)) + Expect(template.Name).To(Equal("template-operator-1.0.0")) By("And annotations should be correct") annotations := template.Annotations @@ -308,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")) @@ -342,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")) @@ -389,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] @@ -464,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")) @@ -495,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")) @@ -533,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")) @@ -547,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, } @@ -571,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"))