Skip to content

Commit

Permalink
Short-circuit createArgoProject and createArgoApp
Browse files Browse the repository at this point in the history
Return silently if an AppProject or Application with the requested name
already exists.
  • Loading branch information
simu committed Dec 18, 2024
1 parent 28f2878 commit 30572d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/argocd/argo-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func createArgoProject(ctx context.Context, cluster *api.Cluster, config *rest.C
return err
}
argoProjectClient := dynamicClient.Resource(argoProjectGVR)

if _, err = argoProjectClient.Namespace(namespace).Get(ctx, name, v1.GetOptions{}); err == nil {
return nil
}

project := &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": argoProjectGVR.Group + "/" + argoProjectGVR.Version,
Expand Down Expand Up @@ -99,6 +104,11 @@ func createArgoApp(ctx context.Context, cluster *api.Cluster, config *rest.Confi
return err
}
argoAppClient := dynamicClient.Resource(argoAppGVR)

if _, err = argoAppClient.Namespace(namespace).Get(ctx, name, v1.GetOptions{}); err == nil {
return nil
}

app := &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": argoAppGVR.Group + "/" + argoAppGVR.Version,
Expand Down

0 comments on commit 30572d2

Please sign in to comment.