Skip to content

Commit

Permalink
Merge branch 'main' into feat/cache_check
Browse files Browse the repository at this point in the history
  • Loading branch information
medmes authored Jan 22, 2025
2 parents 51a7d9c + 4530763 commit a46743f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/v1beta2/modulereleasemeta_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ type ModuleReleaseMetaSpec struct {
Channels []ChannelVersionAssignment `json:"channels"`

// Beta indicates if the module is in beta state. Beta modules are only available for beta Kymas.
// +optional
// +kubebuilder:default:=false
Beta bool `json:"beta,omitempty"`
Beta bool `json:"beta"`

// Internal indicates if the module is internal. Internal modules are only available for internal Kymas.
// +optional
// +kubebuilder:default:=false
Internal bool `json:"internal,omitempty"`
Internal bool `json:"internal"`
}

// +kubebuilder:object:root=true
Expand Down
40 changes: 38 additions & 2 deletions pkg/testutils/modulereleasemeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
"github.com/kyma-project/lifecycle-manager/pkg/util"
)

var ErrNotExpectedChannelVersion = errors.New("channel-version pair not found")
var (
ErrNotExpectedChannelVersion = errors.New("channel-version pair not found")
ErrBetaValueNotCorrect = errors.New("beta value not correct")
ErrInternalValueNotCorrect = errors.New("internal value not correct")
)

func UpdateChannelVersionInModuleReleaseMeta(ctx context.Context, clnt client.Client,
moduleName, namespace, channel, version string,
Expand Down Expand Up @@ -75,7 +79,9 @@ func SetModuleReleaseMetaBeta(ctx context.Context, beta bool, moduleName, namesp
return nil
}

func SetModuleReleaseMetaInternal(ctx context.Context, internal bool, moduleName, namespace string, clnt client.Client) error {
func SetModuleReleaseMetaInternal(ctx context.Context, internal bool, moduleName, namespace string,
clnt client.Client,
) error {
mrm, err := GetModuleReleaseMeta(ctx, moduleName, namespace, clnt)
if err != nil {
return fmt.Errorf("failed to fetch modulereleasemeta, %w", err)
Expand Down Expand Up @@ -147,3 +153,33 @@ func UpdateAllModuleReleaseMetaChannelVersions(ctx context.Context, client clien
}
return nil
}

func ModuleReleaseMetaBetaValueIsCorrect(ctx context.Context, client client.Client, namespace, name string,
expectedValue bool,
) error {
meta := &v1beta2.ModuleReleaseMeta{}
if err := client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, meta); err != nil {
return err
}

if meta.IsBeta() != expectedValue {
return ErrBetaValueNotCorrect
}

return nil
}

func ModuleReleaseMetaInternalValueIsCorrect(ctx context.Context, client client.Client, namespace, name string,
expectedValue bool,
) error {
meta := &v1beta2.ModuleReleaseMeta{}
if err := client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, meta); err != nil {
return err
}

if meta.IsInternal() != expectedValue {
return ErrInternalValueNotCorrect
}

return nil
}
39 changes: 39 additions & 0 deletions tests/e2e/modulereleasemeta_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,45 @@ var _ = Describe("ModuleReleaseMeta Sync", Ordered, func() {
WithContext(ctx).
WithArguments(module.Name, RemoteNamespace, v1beta2.DefaultChannel, v1Version, skrClient).
Should(Succeed())

By("And the ModuleReleaseMeta has the correct beta and internal values on the SKR Cluster")
Eventually(ModuleReleaseMetaBetaValueIsCorrect).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, module.Name, false).
Should(Succeed())

Eventually(ModuleReleaseMetaInternalValueIsCorrect).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, module.Name, false).
Should(Succeed())
})

It("When Beta value is set to true on the SKR Cluster", func() {
Eventually(SetModuleReleaseMetaBeta).
WithContext(ctx).
WithArguments(true, module.Name, RemoteNamespace, skrClient).
Should(Succeed())
})

It("Then Beta value is reverted back to its value from the KCP Cluster", func() {
Eventually(ModuleReleaseMetaBetaValueIsCorrect).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, module.Name, false).
Should(Succeed())
})

It("When Internal value is set to true on the SKR Cluster", func() {
Eventually(SetModuleReleaseMetaInternal).
WithContext(ctx).
WithArguments(true, module.Name, RemoteNamespace, skrClient).
Should(Succeed())
})

It("Then Internal value is reverted back to its value from the KCP Cluster", func() {
Eventually(ModuleReleaseMetaInternalValueIsCorrect).
WithContext(ctx).
WithArguments(skrClient, RemoteNamespace, module.Name, false).
Should(Succeed())
})

It("When the ModuleReleaseMeta is set to beta", func() {
Expand Down

0 comments on commit a46743f

Please sign in to comment.