From 24e01374449780f51faadfdc1b43ea25c1dc48b4 Mon Sep 17 00:00:00 2001 From: pb Date: Mon, 12 May 2025 15:00:56 +0200 Subject: [PATCH] shortened how targets are named --- infrastructure/kubernetes.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/infrastructure/kubernetes.go b/infrastructure/kubernetes.go index 1e74f24..dd559bd 100644 --- a/infrastructure/kubernetes.go +++ b/infrastructure/kubernetes.go @@ -292,13 +292,20 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, execu return nil, nil // Maybe we could create a wrapper for errors and add more info to have } + s := strings.Split(peerId, "-")[:2] + p := s[0] + "-" + s[1] + + targetName := "target-" + p + "-" + executionId target := map[string]interface{}{ "apiVersion": "multicluster.admiralty.io/v1alpha1", "kind": "Target", "metadata": map[string]interface{}{ - "name": "target-" + peerId + "-" +executionId, + "name": targetName, "namespace": executionId, + "labels": map[string]interface{}{ + "peer": peerId, + }, }, "spec": map[string]interface{}{ "kubeconfigSecret": map[string]string{ @@ -307,7 +314,7 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, execu }, } - res, err := dynamicClientApply(executionId, "target-" + peerId + "-" +executionId, gvrTargets, context, target) + res, err := dynamicClientApply(executionId, targetName, gvrTargets, context, target) if err != nil { return nil, errors.New("Error when trying to apply Target definition :" + err.Error()) }