Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz-Smelcerz-SAP committed Sep 26, 2024
1 parent e374157 commit 3bd7877
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 81 deletions.
6 changes: 3 additions & 3 deletions internal/controller/kyma/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/manifest/parser/template_to_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/templatelookup/regular.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/templatelookup/regular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/module_install_by_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ 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())
})

It("Then Module CR exists", 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())
})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/kyma/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions unit-test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

65 changes: 0 additions & 65 deletions verification.sh

This file was deleted.

0 comments on commit 3bd7877

Please sign in to comment.