Skip to content

Commit

Permalink
Merge branch 'transparent_managed_by' into managedby_label
Browse files Browse the repository at this point in the history
  • Loading branch information
nesmabadr authored Sep 26, 2024
2 parents ec2bd89 + 25d869f commit c45c1c2
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion api/v1beta2/kyma_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (kyma *Kyma) EnsureLabelsAndFinalizers() bool {
}

if _, ok := kyma.ObjectMeta.Labels[shared.ManagedBy]; !ok {
kyma.ObjectMeta.Labels[shared.ManagedBy] = shared.OperatorName
kyma.ObjectMeta.Labels[shared.ManagedBy] = shared.KymaLabelValue
updateRequired = true
}
return updateRequired
Expand Down
2 changes: 1 addition & 1 deletion pkg/module/common/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (m *Module) ApplyDefaultMetaToManifest(kyma *v1beta2.Kyma) {
}
lbls[shared.ModuleName] = m.ModuleName
lbls[shared.ChannelLabel] = m.Template.Spec.Channel
lbls[shared.ManagedBy] = shared.OperatorName
lbls[shared.ManagedBy] = shared.KymaLabelValue
if m.Template.Spec.Mandatory {
lbls[shared.IsMandatoryModule] = shared.EnableLabelValue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/module/common/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestApplyDefaultMetaToManifest_WhenCalled_SetsManagedByLabel(t *testing.T)
module.ApplyDefaultMetaToManifest(kyma)

resultLabels := module.GetLabels()
assert.Equal(t, "lifecycle-manager", resultLabels["operator.kyma-project.io/managed-by"])
assert.Equal(t, "kyma", resultLabels["operator.kyma-project.io/managed-by"])
}

func TestApplyDefaultMetaToManifest_WhenCalled_SetsFQDNAnnotation(t *testing.T) {
Expand Down
12 changes: 4 additions & 8 deletions pkg/testutils/builder/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ func NewWatcherBuilder() *WatcherBuilder {
builder := &WatcherBuilder{
watcher: &v1beta2.Watcher{},
}
builder.watcher.SetLabels(
map[string]string{
shared.ManagedBy: shared.KymaLabelValue,
})

namespace := random.Name()

return builder.
WithName(random.Name()).
WithNamespace(namespace).
WithManager(random.Name()).
WithServiceInfoName(random.Name()).
WithServiceInfoNamespace(namespace).
WithServiceInfoPort(random.Port()).
Expand All @@ -46,13 +49,6 @@ func (builder *WatcherBuilder) WithNamespace(namespace string) *WatcherBuilder {
return builder
}

func (builder *WatcherBuilder) WithManager(manager string) *WatcherBuilder {
builder.watcher.Labels = map[string]string{
shared.ManagedBy: manager,
}
return builder
}

func (builder *WatcherBuilder) WithServiceInfoName(name string) *WatcherBuilder {
builder.watcher.Spec.ServiceInfo.Name = name
return builder
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewTestIssuer(namespace string) *certmanagerv1.Issuer {
Namespace: namespace,
Labels: k8slabels.Set{
shared.PurposeLabel: shared.CertManager,
shared.ManagedBy: shared.OperatorName,
shared.ManagedBy: shared.KymaLabelValue,
},
},
Spec: certmanagerv1.IssuerSpec{
Expand Down
2 changes: 1 addition & 1 deletion pkg/watch/mandatory_template_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h *MandatoryTemplateChangeHandler) Watch() handler.MapFunc {
func getKymaList(ctx context.Context, clnt client.Reader) (*v1beta2.KymaList, error) {
kymas := &v1beta2.KymaList{}
listOptions := &client.ListOptions{
LabelSelector: k8slabels.SelectorFromSet(k8slabels.Set{shared.ManagedBy: shared.OperatorName}),
LabelSelector: k8slabels.SelectorFromSet(k8slabels.Set{shared.ManagedBy: shared.KymaLabelValue}),
}
err := clnt.List(ctx, kymas, listOptions)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/watcher/certificate_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func NewCertificateManager(kcpClient client.Client, kymaName string,
caCertCache: caCertCache,
labelSet: k8slabels.Set{
shared.PurposeLabel: shared.CertManager,
shared.ManagedBy: shared.OperatorName,
shared.ManagedBy: shared.KymaLabelValue,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func registerControlPlaneLifecycleForKyma(kyma *v1beta2.Kyma) {
WithContext(ctx).
WithArguments(kcpClient, template).Should(Succeed())
// Set labels and state manual, since we do not start the Kyma Controller
kyma.Labels[shared.ManagedBy] = shared.OperatorName
kyma.Labels[shared.ManagedBy] = shared.KymaLabelValue
Eventually(CreateCR).
WithContext(ctx).
WithArguments(kcpClient, kyma).Should(Succeed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func registerControlPlaneLifecycleForKyma(kyma *v1beta2.Kyma) {
WithContext(ctx).
WithArguments(kcpClient, template).Should(Succeed())
// Set labels and state manual, since we do not start the Kyma Controller
kyma.Labels[shared.ManagedBy] = shared.OperatorName
kyma.Labels[shared.ManagedBy] = shared.KymaLabelValue
Eventually(CreateCR).
WithContext(ctx).
WithArguments(kcpClient, kyma).Should(Succeed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func createCaCertificate() *certmanagerv1.Certificate {
SecretName: "klm-watcher-root-secret",
SecretTemplate: &certmanagerv1.CertificateSecretTemplate{
Labels: map[string]string{
shared.ManagedBy: shared.OperatorName,
shared.ManagedBy: shared.KymaLabelValue,
},
},
PrivateKey: &certmanagerv1.CertificatePrivateKey{
Expand All @@ -167,7 +167,7 @@ func createWatcherCR(managerInstanceName string, statusOnly bool) *v1beta2.Watch
Name: managerInstanceName,
Namespace: kcpSystemNs,
Labels: map[string]string{
shared.ManagedBy: managerInstanceName,
shared.ManagedBy: shared.KymaLabelValue,
},
},
Spec: v1beta2.WatcherSpec{
Expand Down Expand Up @@ -198,7 +198,7 @@ func createTLSSecret(kymaObjKey client.ObjectKey) *apicorev1.Secret {
Name: watcher.ResolveTLSCertName(kymaObjKey.Name),
Namespace: istioSystemNs,
Labels: map[string]string{
shared.ManagedBy: shared.OperatorName,
shared.ManagedBy: shared.KymaLabelValue,
},
},
Data: map[string][]byte{
Expand Down

0 comments on commit c45c1c2

Please sign in to comment.