when creating source or target returns a 409, don't return an error. Post should be replaced by Put but not working

This commit is contained in:
pb
2025-04-10 14:22:37 +02:00
parent 2cf8923d95
commit cca59faeab
2 changed files with 11 additions and 3 deletions

View File

@@ -277,7 +277,7 @@ func (k *KubernetesService) CreateAdmiraltyTarget(context context.Context,execut
err = tmpl.Execute(&tpl, map[string]string{"ExecutionId":executionId})
targetManifest = tpl.String()
resp, err := postCDRapiKube(
resp, err := putCDRapiKube(
*k.Set,
context,
"/apis/multicluster.admiralty.io/v1alpha1/namespaces/"+ executionId +"/targets",
@@ -316,7 +316,7 @@ func (k *KubernetesService) CreateAdmiraltySource(context context.Context,execut
err = tmpl.Execute(&tpl, map[string]string{"ExecutionId":executionId})
sourceManifest = tpl.String()
resp, err := postCDRapiKube(
resp, err := putCDRapiKube(
*k.Set,
context,
"/apis/multicluster.admiralty.io/v1alpha1/namespaces/"+ executionId +"/sources",
@@ -326,6 +326,7 @@ func (k *KubernetesService) CreateAdmiraltySource(context context.Context,execut
)
// We can add more info to the log with the content of resp if not nil
if err != nil {
fmt.Println("Error trying to create a Source on remote cluster : ", err , " : ", resp)
return nil, err
@@ -431,7 +432,7 @@ func getCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string
return resp, nil
}
func postCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string, body []byte, params ...map[string]string) ([]byte, error){
func putCDRapiKube(client kubernetes.Clientset, ctx context.Context, path string, body []byte, params ...map[string]string) ([]byte, error){
req := client.RESTClient().
Post().
AbsPath(path).