diff --git a/internal/controller/kyma/controller.go b/internal/controller/kyma/controller.go index e59b75484b..55b6c833a6 100644 --- a/internal/controller/kyma/controller.go +++ b/internal/controller/kyma/controller.go @@ -34,7 +34,7 @@ import ( "github.com/kyma-project/lifecycle-manager/api/v1beta2" "github.com/kyma-project/lifecycle-manager/internal/descriptor/provider" "github.com/kyma-project/lifecycle-manager/internal/event" - parse "github.com/kyma-project/lifecycle-manager/internal/manifest/parser" + "github.com/kyma-project/lifecycle-manager/internal/manifest/parser" "github.com/kyma-project/lifecycle-manager/internal/pkg/metrics" "github.com/kyma-project/lifecycle-manager/internal/remote" "github.com/kyma-project/lifecycle-manager/pkg/log" @@ -490,8 +490,8 @@ func (r *Reconciler) updateKyma(ctx context.Context, kyma *v1beta2.Kyma) error { func (r *Reconciler) reconcileManifests(ctx context.Context, kyma *v1beta2.Kyma) error { templates := templatelookup.NewTemplateLookup(client.Reader(r), r.DescriptorProvider).GetRegularTemplates(ctx, kyma) - parser := parse.NewParser(r.Client, r.DescriptorProvider, r.InKCPMode, r.RemoteSyncNamespace) - modules := parser.GenerateModulesFromTemplates(kyma, templates) + prsr := parser.NewParser(r.Client, r.DescriptorProvider, r.InKCPMode, r.RemoteSyncNamespace) + modules := prsr.GenerateModulesFromTemplates(kyma, templates) runner := sync.New(r) if err := runner.ReconcileManifests(ctx, kyma, modules); err != nil { diff --git a/internal/manifest/parser/template_to_module.go b/internal/manifest/parser/template_to_module.go index 87bc5a9935..96532dd552 100644 --- a/internal/manifest/parser/template_to_module.go +++ b/internal/manifest/parser/template_to_module.go @@ -45,7 +45,7 @@ func (p *Parser) GenerateModulesFromTemplates(kyma *v1beta2.Kyma, templates temp // (since we do not know which module we are dealing with) modules := make(common.Modules, 0) - for _, module := range kyma.GetAvailableModules() { + for _, module := range templatelookup.FindAvailableModules(kyma) { template := templates[module.Name] modules = p.appendModuleWithInformation(module, kyma, template, modules) } @@ -67,7 +67,7 @@ func (p *Parser) GenerateMandatoryModulesFromTemplates(ctx context.Context, moduleName = template.Name } - modules = p.appendModuleWithInformation(v1beta2.AvailableModule{ + modules = p.appendModuleWithInformation(templatelookup.AvailableModule{ Module: v1beta2.Module{ Name: moduleName, CustomResourcePolicy: v1beta2.CustomResourcePolicyCreateAndDelete, @@ -79,7 +79,7 @@ func (p *Parser) GenerateMandatoryModulesFromTemplates(ctx context.Context, return modules } -func (p *Parser) appendModuleWithInformation(module v1beta2.AvailableModule, kyma *v1beta2.Kyma, +func (p *Parser) appendModuleWithInformation(module templatelookup.AvailableModule, kyma *v1beta2.Kyma, template *templatelookup.ModuleTemplateInfo, modules common.Modules, ) common.Modules { if template.Err != nil && !errors.Is(template.Err, templatelookup.ErrTemplateNotAllowed) { diff --git a/pkg/templatelookup/regular.go b/pkg/templatelookup/regular.go index 4a24a64c61..8c16c60b4b 100644 --- a/pkg/templatelookup/regular.go +++ b/pkg/templatelookup/regular.go @@ -291,7 +291,6 @@ func (t *TemplateLookup) getTemplateByVersion(ctx context.Context, name, version var filteredTemplates []*v1beta2.ModuleTemplate for _, template := range templateList.Items { - template := template if TemplateNameMatch(&template, name) && shared.NoneChannel.Equals(template.Spec.Channel) && template.Spec.Version == version { filteredTemplates = append(filteredTemplates, &template) continue diff --git a/pkg/templatelookup/regular_test.go b/pkg/templatelookup/regular_test.go index 3ce08511b7..64e738fc69 100644 --- a/pkg/templatelookup/regular_test.go +++ b/pkg/templatelookup/regular_test.go @@ -751,7 +751,6 @@ func TestTemplateNameMatch(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { if got := templatelookup.TemplateNameMatch(&tt.template, targetName); got != tt.want { assert.Equal(t, tt.want, got) diff --git a/tests/e2e/module_install_by_version_test.go b/tests/e2e/module_install_by_version_test.go index 01bc104457..b730f59e69 100644 --- a/tests/e2e/module_install_by_version_test.go +++ b/tests/e2e/module_install_by_version_test.go @@ -25,7 +25,7 @@ var _ = Describe("Module Install By Version", Ordered, func() { Skip("Version attribute is disabled for now on the CRD level") Eventually(EnableModule). WithContext(ctx). - WithArguments(runtimeClient, defaultRemoteKymaName, RemoteNamespace, templateOperatorModule). + WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, templateOperatorModule). Should(Succeed()) }) @@ -33,24 +33,24 @@ var _ = Describe("Module Install By Version", Ordered, func() { Skip("Version attribute is disabled for now on the CRD level") Eventually(ModuleCRExists). WithContext(ctx). - WithArguments(runtimeClient, moduleCR). + WithArguments(skrClient, moduleCR). Should(Succeed()) By("And Module Operator Deployment exists") Eventually(DeploymentIsReady). WithContext(ctx). - WithArguments(runtimeClient, ModuleDeploymentNameInNewerVersion, TestModuleResourceNamespace). + WithArguments(skrClient, ModuleDeploymentNameInNewerVersion, TestModuleResourceNamespace). Should(Succeed()) By("And KCP Kyma CR is in \"Ready\" State") Eventually(KymaIsInState). WithContext(ctx). - WithArguments(kyma.GetName(), kyma.GetNamespace(), controlPlaneClient, shared.StateReady). + WithArguments(kyma.GetName(), kyma.GetNamespace(), kcpClient, shared.StateReady). Should(Succeed()) By("And Module is in \"Ready\" State") Eventually(CheckModuleState). WithContext(ctx). - WithArguments(controlPlaneClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name, shared.StateReady). + WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name, shared.StateReady). Should(Succeed()) }) }) diff --git a/tests/integration/controller/kyma/manifest_test.go b/tests/integration/controller/kyma/manifest_test.go index ad3f887d7e..28622caf17 100644 --- a/tests/integration/controller/kyma/manifest_test.go +++ b/tests/integration/controller/kyma/manifest_test.go @@ -337,7 +337,7 @@ var _ = Describe("Modules can only be referenced via module name", Ordered, func moduleReferencedWithNamespacedName := NewTestModule( v1beta2.DefaultChannel+shared.Separator+"random-module", v1beta2.DefaultChannel) moduleReferencedWithFQDN := NewTestModuleWithFixName("kyma-project.io/module/"+"random-module", - v1beta2.DefaultChannel) + v1beta2.DefaultChannel, "") kyma.Spec.Modules = append(kyma.Spec.Modules, moduleReferencedWithLabel) RegisterDefaultLifecycleForKyma(kyma) diff --git a/unit-test-coverage.yaml b/unit-test-coverage.yaml index e1fd5085fd..0200d746e2 100644 --- a/unit-test-coverage.yaml +++ b/unit-test-coverage.yaml @@ -6,8 +6,8 @@ packages: internal/manifest/statecheck: 66 internal/manifest/filemutex: 100 internal/manifest: 7 - internal/istio: 63.5 - internal/pkg/resources: 91.8 + internal/istio: 63.3 + internal/pkg/resources: 91.7 internal/remote: 6.6 pkg/templatelookup: 72 diff --git a/verification.sh b/verification.sh deleted file mode 100755 index 50f7565aeb..0000000000 --- a/verification.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -COMMIT_BASE="a180040ef2e6b8742a61ccc44eaaabae1dded8f5" - -FILE=".github/actions/deploy-template-operator/action.yaml" -FILE=".github/workflows/test-e2e.yaml" -FILE="api-version-compatibility-config.yaml" -FILE="api/shared/channel.go" -FILE="api/v1beta2/kyma_types.go" -FILE="api/v1beta2/moduletemplate_types.go" -FILE="api/v1beta2/moduletemplate_types_test.go" -FILE="api/v1beta2/zz_generated.deepcopy.go" -FILE="config/crd/bases/operator.kyma-project.io_moduletemplates.yaml" -FILE="internal/controller/kyma/controller.go" -FILE="internal/descriptor/cache/key.go" -FILE="internal/descriptor/provider/provider_test.go" -FILE="internal/pkg/metrics/kyma.go" -FILE="internal/remote/skr_context.go" -FILE="internal/remote/skr_context_test.go" -FILE="pkg/templatelookup/availableModules.go" -FILE="pkg/templatelookup/availableModules_test.go" -FILE="pkg/templatelookup/regular.go" -FILE="pkg/templatelookup/regular_test.go" -FILE="pkg/testutils/builder/moduletemplate.go" -FILE="pkg/testutils/moduletemplate.go" -FILE="pkg/testutils/utils.go" -FILE="tests/e2e/Makefile" -FILE="tests/e2e/module_install_by_version_test.go" -FILE="tests/e2e/module_status_decoupling_test.go" -FILE="tests/integration/apiwebhook/moduletemplate_crd_validation_test.go" -FILE="tests/integration/apiwebhook/ocm_test.go" -FILE="tests/integration/controller/kcp/helper_test.go" -FILE="tests/integration/controller/kcp/remote_sync_test.go" -FILE="tests/integration/controller/kyma/helper_test.go" -FILE="tests/integration/controller/kyma/kyma_module_channel_test.go" -FILE="tests/integration/controller/kyma/kyma_module_enable_test.go" -FILE="tests/integration/controller/kyma/kyma_module_version_test.go" -FILE="tests/integration/controller/kyma/kyma_test.go" -#TODO!FILE="tests/integration/controller/kyma/manifest_test.go" -FILE="tests/integration/controller/kyma/moduletemplate_install_test.go" -FILE="tests/integration/controller/kyma/moduletemplate_test.go" -FILE="tests/integration/controller/mandatorymodule/deletion/controller_test.go" -FILE="tests/integration/controller/mandatorymodule/installation/controller_test.go" -FILE="tests/integration/controller/moduletemplate/moduletemplate_test.go" -FILE="tests/integration/controller/moduletemplate/suite_test.go" -FILE="tests/moduletemplates/moduletemplate_template_operator_v2_direct_version.yaml" -#TODO!FILE="unit-test-coverage.yaml" - -#2nd round: -FILE="api/v1beta2/kyma_types.go" -FILE="internal/controller/kyma/controller.go" -#FILE="pkg/module/parse/template_to_module.go" -FILE="pkg/templatelookup/regular.go" -FILE="tests/integration/controller/kyma/manifest_test.go" -FILE="unit-test-coverage.yaml" - -git diff $COMMIT_BASE feat/module-catalogue-improvements $FILE > old.diff -git diff main $FILE > new.diff - -#NOTES -# internal/remote/skr_context_test.go: in commit 98811dee24447a000f82a0e1ed401db62e004b8d the "testCase" variable is modified -> possible bug -# check: "pkg/module/parse/template_to_module.go" for changes. -# -# -#