Skip to content

Commit

Permalink
Only distribute templates that are managed by KCM template chains
Browse files Browse the repository at this point in the history
Closes #705
  • Loading branch information
eromanova committed Jan 20, 2025
1 parent 438998e commit c9982fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/controller/templatechain_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func (r *TemplateChainReconciler) ReconcileTemplateChain(ctx context.Context, te
return ctrl.Result{}, err
}

if templateChain.GetNamespace() == r.SystemNamespace {
if templateChain.GetNamespace() == r.SystemNamespace ||
templateChain.GetLabels()[kcm.KCMManagedLabelKey] != kcm.KCMManagedLabelValue {
return ctrl.Result{}, nil
}

Expand Down
10 changes: 8 additions & 2 deletions internal/controller/templatechain_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ var _ = Describe("Template Chain Controller", func() {
ObjectMeta: metav1.ObjectMeta{
Name: chain.Name,
Namespace: chain.Namespace,
Labels: map[string]string{kcmv1.GenericComponentLabelName: kcmv1.GenericComponentLabelValueKCM},
Labels: map[string]string{
kcmv1.GenericComponentLabelName: kcmv1.GenericComponentLabelValueKCM,
kcmv1.KCMManagedLabelKey: kcmv1.KCMManagedLabelValue,
},
},
Spec: kcmv1.TemplateChainSpec{SupportedTemplates: supportedClusterTemplates[chain.Name]},
}
Expand All @@ -186,7 +189,10 @@ var _ = Describe("Template Chain Controller", func() {
ObjectMeta: metav1.ObjectMeta{
Name: chain.Name,
Namespace: chain.Namespace,
Labels: map[string]string{kcmv1.GenericComponentLabelName: kcmv1.GenericComponentLabelValueKCM},
Labels: map[string]string{
kcmv1.GenericComponentLabelName: kcmv1.GenericComponentLabelValueKCM,
kcmv1.KCMManagedLabelKey: kcmv1.KCMManagedLabelValue,
},
},
Spec: kcmv1.TemplateChainSpec{SupportedTemplates: supportedServiceTemplates[chain.Name]},
}
Expand Down

0 comments on commit c9982fc

Please sign in to comment.