diff --git a/.golangci.yaml b/.golangci.yaml index 3598b1a9c3..6e3a796b0c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -181,11 +181,7 @@ issues: - err113 # Dynamic error creation in unit and integration test utils is ok - path: tests/e2e/ linters: [ gci ] # Disable gci due to the test utilities dot import. - - path: tests/integration/watcher/certificate_suite_test.go - linters: [ gci ] # Disable gci due to the test utilities dot import. - - path: tests/integration/declarative/declarative_test.go - linters: [ gci ] # Disable gci due to the test utilities dot import. - - path: tests/integration/controller/(.*)/(.*)_test.go + - path: tests/integration/ linters: [ gci ] # Disable gci due to the test utilities dot import. - linters: - importas diff --git a/docs/contributor/04-local-test-setup.md b/docs/contributor/04-local-test-setup.md index b4c9f5eb78..4a269e1c61 100644 --- a/docs/contributor/04-local-test-setup.md +++ b/docs/contributor/04-local-test-setup.md @@ -117,7 +117,7 @@ This setup is deployed with the following security features enabled: The output should look like the following: ```shell - {"repositories":["component-descriptors/kyma-project.io/template-operator"]} + {"repositories":["component-descriptors/kyma-project.io/module/template-operator"]} ``` 7. Open the generated `template.yaml` file and change the following line: @@ -240,7 +240,7 @@ status: operation: kyma is ready modules: - channel: regular - fqdn: kyma-project.io/template-operator + fqdn: kyma-project.io/module/template-operator manifest: apiVersion: operator.kyma-project.io/v1beta2 kind: Manifest diff --git a/pkg/testutils/builder/manifest.go b/pkg/testutils/builder/manifest.go index e7a4962689..a7170d88dc 100644 --- a/pkg/testutils/builder/manifest.go +++ b/pkg/testutils/builder/manifest.go @@ -18,7 +18,7 @@ func NewManifestBuilder() ManifestBuilder { manifest: &v1beta2.Manifest{ TypeMeta: apimetav1.TypeMeta{ APIVersion: v1beta2.GroupVersion.String(), - Kind: "Manifest", + Kind: string(shared.ManifestKind), }, ObjectMeta: apimetav1.ObjectMeta{ Name: random.Name(), diff --git a/pkg/testutils/manifest.go b/pkg/testutils/manifest.go index f9d2f0efff..c1cb38b0e5 100644 --- a/pkg/testutils/manifest.go +++ b/pkg/testutils/manifest.go @@ -48,7 +48,7 @@ var ( func NewTestManifest(prefix string) *v1beta2.Manifest { return builder.NewManifestBuilder().WithName(fmt.Sprintf("%s-%s", prefix, - random.Name())).WithNamespace(apimetav1.NamespaceDefault).WithLabel(shared.KymaName, + random.Name())).WithNamespace(ControlPlaneNamespace).WithLabel(shared.KymaName, string(uuid.NewUUID())).Build() } @@ -648,7 +648,7 @@ func GetManifestWithName(ctx context.Context, clnt client.Client, manifestName s manifest := &v1beta2.Manifest{} err := clnt.Get( ctx, client.ObjectKey{ - Namespace: apimetav1.NamespaceDefault, + Namespace: ControlPlaneNamespace, Name: manifestName, }, manifest, ) diff --git a/pkg/testutils/ocm.go b/pkg/testutils/ocm.go new file mode 100644 index 0000000000..8fe58e6799 --- /dev/null +++ b/pkg/testutils/ocm.go @@ -0,0 +1,3 @@ +package testutils + +const DefaultFQDN = "kyma-project.io/module/template-operator" diff --git a/tests/integration/controller/mandatorymodule/deletion/controller_test.go b/tests/integration/controller/mandatorymodule/deletion/controller_test.go index becc40a2db..84407bc44c 100644 --- a/tests/integration/controller/mandatorymodule/deletion/controller_test.go +++ b/tests/integration/controller/mandatorymodule/deletion/controller_test.go @@ -21,10 +21,9 @@ import ( . "github.com/kyma-project/lifecycle-manager/pkg/testutils" ) -var ErrNoMandatoryManifest = errors.New("manifest for mandatory Module not found") - const ( mandatoryChannel = "dummychannel" + mandatoryModule = "mandatory-module" ) var _ = Describe("Mandatory Module Deletion", Ordered, func() { @@ -39,14 +38,14 @@ var _ = Describe("Mandatory Module Deletion", Ordered, func() { Should(Succeed()) Eventually(MandatoryManifestExistsWithLabelAndAnnotation). WithContext(ctx). - WithArguments(kcpClient, shared.FQDN, "kyma-project.io/template-operator"). + WithArguments(kcpClient, shared.FQDN, DefaultFQDN). Should(Succeed()) By("And mandatory finalizer is added to the mandatory ModuleTemplate", func() { Eventually(mandatoryModuleTemplateFinalizerExists). WithContext(ctx). WithArguments(kcpClient, client.ObjectKey{ Namespace: ControlPlaneNamespace, - Name: "mandatory-module", + Name: mandatoryModule, }). Should(Succeed()) }) @@ -62,14 +61,14 @@ var _ = Describe("Mandatory Module Deletion", Ordered, func() { It("Then mandatory Manifest is deleted", func() { Eventually(MandatoryManifestExistsWithLabelAndAnnotation). WithContext(ctx). - WithArguments(kcpClient, shared.FQDN, "kyma-project.io/template-operator"). + WithArguments(kcpClient, shared.FQDN, DefaultFQDN). Should(Not(Succeed())) By("And finalizer is removed from mandatory ModuleTemplate", func() { Eventually(mandatoryModuleTemplateFinalizerExists). WithContext(ctx). WithArguments(kcpClient, client.ObjectKey{ Namespace: ControlPlaneNamespace, - Name: "mandatory-module", + Name: mandatoryModule, }). Should(Not(Succeed())) }) @@ -80,12 +79,12 @@ var _ = Describe("Mandatory Module Deletion", Ordered, func() { func registerControlPlaneLifecycleForKyma(kyma *v1beta2.Kyma) { template := builder.NewModuleTemplateBuilder(). WithNamespace(ControlPlaneNamespace). - WithName("mandatory-module"). - WithLabelModuleName("mandatory-module"). + WithName(mandatoryModule). + WithLabelModuleName(mandatoryModule). WithChannel(mandatoryChannel). WithMandatory(true). WithOCM(compdescv2.SchemaVersion).Build() - mandatoryManifest := NewTestManifest("mandatory-module") + mandatoryManifest := NewTestManifest(mandatoryModule) mandatoryManifest.Labels[shared.IsMandatoryModule] = "true" BeforeAll(func() { @@ -102,7 +101,7 @@ func registerControlPlaneLifecycleForKyma(kyma *v1beta2.Kyma) { WithArguments(kyma, reconciler, shared.StateReady).Should(Succeed()) installName := filepath.Join("main-dir", "installs") - mandatoryManifest.Annotations = map[string]string{shared.FQDN: "kyma-project.io/template-operator"} + mandatoryManifest.Annotations = map[string]string{shared.FQDN: DefaultFQDN} validImageSpec, err := CreateOCIImageSpecFromFile(installName, server.Listener.Addr().String(), manifestFilePath, false) diff --git a/tests/integration/controller/mandatorymodule/deletion/suite_test.go b/tests/integration/controller/mandatorymodule/deletion/suite_test.go index 7745ce8c79..368fe36e80 100644 --- a/tests/integration/controller/mandatorymodule/deletion/suite_test.go +++ b/tests/integration/controller/mandatorymodule/deletion/suite_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-containerregistry/pkg/registry" "go.uber.org/zap/zapcore" + apicorev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" k8sclientscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" @@ -95,6 +96,7 @@ var _ = BeforeSuite(func() { Expect(api.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) Expect(apiextensionsv1.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) + Expect(apicorev1.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme diff --git a/tests/integration/controller/mandatorymodule/installation/controller_test.go b/tests/integration/controller/mandatorymodule/installation/controller_test.go index f1d0bcb34b..3d6268025f 100644 --- a/tests/integration/controller/mandatorymodule/installation/controller_test.go +++ b/tests/integration/controller/mandatorymodule/installation/controller_test.go @@ -56,7 +56,7 @@ var _ = Describe("Mandatory Module Installation", Ordered, func() { It("And Manifest CR for the Mandatory Module should be created with correct Owner Reference", func() { Eventually(checkMandatoryManifestForKyma). WithContext(ctx). - WithArguments(kyma, "kyma-project.io/template-operator"). + WithArguments(kyma, DefaultFQDN). Should(Succeed()) }) }) @@ -71,7 +71,7 @@ var _ = Describe("Skipping Mandatory Module Installation", Ordered, func() { It("When Kyma has 'skip-reconciliation' label, then no Mandatory Module Manifest should be created", func() { Eventually(checkMandatoryManifestForKyma). WithContext(ctx). - WithArguments(kyma, "kyma-project.io/template-operator"). + WithArguments(kyma, DefaultFQDN). Should(Equal(ErrNoMandatoryManifest)) }) }) diff --git a/tests/integration/controller/mandatorymodule/installation/suite_test.go b/tests/integration/controller/mandatorymodule/installation/suite_test.go index 01f84f9e35..6a77125541 100644 --- a/tests/integration/controller/mandatorymodule/installation/suite_test.go +++ b/tests/integration/controller/mandatorymodule/installation/suite_test.go @@ -23,6 +23,7 @@ import ( "time" "go.uber.org/zap/zapcore" + apicorev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" k8sclientscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" @@ -86,6 +87,7 @@ var _ = BeforeSuite(func() { Expect(api.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) Expect(apiextensionsv1.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) + Expect(apicorev1.AddToScheme(k8sclientscheme.Scheme)).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme