added a new parameter to the /admiralty/targets route to specify the peerId of the peer targeted, allowing to name differently peers targeted in a namespace

This commit is contained in:
pb
2025-05-05 16:13:49 +02:00
parent 03f81c66f9
commit 8e8d0d3e01
3 changed files with 12 additions and 4 deletions

View File

@@ -19,7 +19,7 @@ type Infrastructure interface {
CreateAdmiraltySource(context context.Context,executionId string) ([]byte, error)
CreateKubeconfigSecret(context context.Context,kubeconfig string, executionId string) ([]byte, error)
GetKubeconfigSecret(context context.Context,executionId string) ([]byte, error)
CreateAdmiraltyTarget(context context.Context,executionId string)([]byte,error)
CreateAdmiraltyTarget(context context.Context,executionId string, peerId string)([]byte,error)
GetOneNode(context context.Context,executionID string) (*v1.Node, error)
}

View File

@@ -280,7 +280,7 @@ func (k *KubernetesService) GetTargets(ctx context.Context) ([]string, error) {
// - have declared the same namespace as the one where the pods are created in the local cluster
//
// - have delcared a serviceAccount with sufficient permission to create pods
func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, executionId string) ([]byte, error) {
func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, executionId string, peerId string) ([]byte, error) {
exists, err := k.GetKubeconfigSecret(context, executionId)
if err != nil {
fmt.Println("Error verifying kube-secret before creating target")
@@ -297,7 +297,7 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context, execu
"apiVersion": "multicluster.admiralty.io/v1alpha1",
"kind": "Target",
"metadata": map[string]interface{}{
"name": "target-"+executionId,
"name": "target-" + peerId + "-" +executionId,
"namespace": executionId,
},
"spec": map[string]interface{}{