-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from ksimon1/remove-CT-labels-annotations
remove all common-template labels / annotations in copy task
- Loading branch information
Showing
3 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package templates | ||
|
||
const ( | ||
OpenshiftDocURL = "openshift.io/documentation-url" | ||
OpenshiftProviderDisplayName = "openshift.io/provider-display-name" | ||
OpenshiftSupportURL = "openshift.io/support-url" | ||
|
||
KubevirtDefaultOSVariant = "template.kubevirt.io/default-os-variant" | ||
|
||
TemplateKubevirtProvider = "template.kubevirt.io/provider" | ||
TemplateKubevirtProviderSupportLevel = "template.kubevirt.io/provider-support-level" | ||
TemplateKubevirtProviderURL = "template.kubevirt.io/provider-url" | ||
|
||
OperatorSDKPrimaryResource = "operator-sdk/primary-resource" | ||
OperatorSDKPrimaryResourceType = "operator-sdk/primary-resource-type" | ||
|
||
AppKubernetesComponent = "app.kubernetes.io/component" | ||
AppKubernetesManagedBy = "app.kubernetes.io/managed-by" | ||
AppKubernetesName = "app.kubernetes.io/name" | ||
AppKubernetesPartOf = "app.kubernetes.io/part-of" | ||
AppKubernetesVersion = "app.kubernetes.io/version" | ||
|
||
TemplateVersionLabel = "template.kubevirt.io/version" | ||
TemplateTypeLabel = "template.kubevirt.io/type" | ||
TemplateOsLabelPrefix = "os.template.kubevirt.io/" | ||
TemplateFlavorLabelPrefix = "flavor.template.kubevirt.io/" | ||
TemplateWorkloadLabelPrefix = "workload.template.kubevirt.io/" | ||
TemplateDeprecatedAnnotation = "template.kubevirt.io/deprecated" | ||
|
||
templateTypeBaseValue = "base" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
modules/copy-template/pkg/templates/template-provider_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package templates_test | ||
|
||
import ( | ||
"github.com/kubevirt/kubevirt-tekton-tasks/modules/copy-template/pkg/templates" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
v1 "github.com/openshift/api/template/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var _ = Describe("Template provider", func() { | ||
Context("Common templates informations removed", func() { | ||
It("should remove Common template informations", func() { | ||
tProvider := &templates.TemplateCreator{} | ||
t := &v1.Template{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{ | ||
templates.OpenshiftDocURL: "test", | ||
templates.OpenshiftProviderDisplayName: "test", | ||
templates.OpenshiftSupportURL: "test", | ||
templates.KubevirtDefaultOSVariant: "test", | ||
templates.TemplateKubevirtProvider: "test", | ||
templates.TemplateKubevirtProviderSupportLevel: "test", | ||
templates.TemplateKubevirtProviderURL: "test", | ||
templates.OperatorSDKPrimaryResource: "test", | ||
templates.OperatorSDKPrimaryResourceType: "test", | ||
templates.AppKubernetesComponent: "test", | ||
templates.AppKubernetesManagedBy: "test", | ||
templates.AppKubernetesName: "test", | ||
templates.AppKubernetesPartOf: "test", | ||
templates.AppKubernetesVersion: "test", | ||
templates.TemplateVersionLabel: "test", | ||
templates.TemplateTypeLabel: "test", | ||
templates.TemplateOsLabelPrefix: "test", | ||
templates.TemplateFlavorLabelPrefix: "test", | ||
templates.TemplateWorkloadLabelPrefix: "test", | ||
templates.TemplateDeprecatedAnnotation: "test", | ||
"someOtherLabel": "test", | ||
}, | ||
Annotations: map[string]string{ | ||
templates.OpenshiftDocURL: "test", | ||
templates.OpenshiftProviderDisplayName: "test", | ||
templates.OpenshiftSupportURL: "test", | ||
templates.KubevirtDefaultOSVariant: "test", | ||
templates.TemplateKubevirtProvider: "test", | ||
templates.TemplateKubevirtProviderSupportLevel: "test", | ||
templates.TemplateKubevirtProviderURL: "test", | ||
templates.OperatorSDKPrimaryResource: "test", | ||
templates.OperatorSDKPrimaryResourceType: "test", | ||
templates.AppKubernetesComponent: "test", | ||
templates.AppKubernetesManagedBy: "test", | ||
templates.AppKubernetesName: "test", | ||
templates.AppKubernetesPartOf: "test", | ||
templates.AppKubernetesVersion: "test", | ||
templates.TemplateVersionLabel: "test", | ||
templates.TemplateTypeLabel: "test", | ||
templates.TemplateOsLabelPrefix: "test", | ||
templates.TemplateFlavorLabelPrefix: "test", | ||
templates.TemplateWorkloadLabelPrefix: "test", | ||
templates.TemplateDeprecatedAnnotation: "test", | ||
"someOtherLabel": "test", | ||
}, | ||
}, | ||
} | ||
updatedTemplate := tProvider.UpdateTemplateMetaObject(t) | ||
Expect(len(t.GetLabels())).To(Equal(1)) | ||
Expect(len(t.GetAnnotations())).To(Equal(1)) | ||
|
||
for key, val := range t.GetLabels() { | ||
if key == "someOtherLabel" { | ||
Expect(updatedTemplate.Labels[key]).To(Equal(val)) | ||
} else { | ||
Expect(updatedTemplate.Labels[key]).To(Equal("")) | ||
} | ||
} | ||
for key, val := range t.GetAnnotations() { | ||
if key == "someOtherLabel" { | ||
Expect(updatedTemplate.Labels[key]).To(Equal(val)) | ||
} else { | ||
Expect(updatedTemplate.Labels[key]).To(Equal("")) | ||
} | ||
} | ||
}) | ||
}) | ||
}) |