Skip to content

Commit d760af7

Browse files
committed
Copy annotation also into TenantControlPlane resource
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 4a98610 commit d760af7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

controllers/kamajicontrolplane_controller_resources.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222

2323
var ErrEnqueueBack = errors.New("enqueue back")
2424

25+
const kubecofigSecretKeyAnnotation = "kamaji.clastix.io/kubeconfig-secret-key"
26+
2527
//+kubebuilder:rbac:groups="",resources="secrets",verbs=get;list;watch;create;update;patch
2628

2729
func (r *KamajiControlPlaneReconciler) createRequiredResources(ctx context.Context, cluster capiv1beta1.Cluster, kcp v1alpha1.KamajiControlPlane, tcp *kamajiv1alpha1.TenantControlPlane) (ctrl.Result, error) {
@@ -148,7 +150,7 @@ func (r *KamajiControlPlaneReconciler) createOrUpdateKubeconfig(ctx context.Cont
148150
labels["kamaji.clastix.io/tcp"] = tcp.Name
149151

150152
secretKey := "admin.conf"
151-
v, ok := kcp.GetAnnotations()["kamaji.clastix.io/kubeconfig-secret-key"]
153+
v, ok := kcp.GetAnnotations()[kubecofigSecretKeyAnnotation]
152154
if ok && v != "" {
153155
secretKey = v
154156
}

controllers/kamajicontrolplane_controller_tcp.go

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ func (r *KamajiControlPlaneReconciler) createOrUpdateTenantControlPlane(ctx cont
2323
tcp := &kamajiv1alpha1.TenantControlPlane{}
2424
tcp.Name = kcp.GetName()
2525
tcp.Namespace = kcp.GetNamespace()
26+
if tcp.Annotations == nil {
27+
tcp.Annotations = make(map[string]string)
28+
}
29+
if kubeconfigSecretKey := kcp.Annotations[kubecofigSecretKeyAnnotation]; kubeconfigSecretKey != "" {
30+
tcp.Annotations[kubecofigSecretKeyAnnotation] = kubeconfigSecretKey
31+
} else {
32+
delete(tcp.Annotations, kubecofigSecretKeyAnnotation)
33+
}
2634

2735
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
2836
_, scopeErr := controllerutil.CreateOrUpdate(ctx, r.client, tcp, func() error {

0 commit comments

Comments
 (0)