Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update ModuleTemplate's Metadata name #82

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/service/templategenerator/templategenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
23 changes: 19 additions & 4 deletions tests/e2e/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand All @@ -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,
}
Expand All @@ -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"))
Expand Down
Loading