Skip to content

Commit

Permalink
Move some logic out of SetArgoCDAppRevision function
Browse files Browse the repository at this point in the history
  • Loading branch information
Oded-B committed Jul 24, 2024
1 parent adc08ad commit 779e66f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,22 @@ func findArgocdAppByManifestPathAnnotation(ctx context.Context, componentPath st
return nil, nil
}

func findArgocdApp(ctx context.Context, componentPath string, repo string, appClient application.ApplicationServiceClient, useSHALabelForArgoDicovery bool) (app *argoappv1.Application, err error) {
f := findArgocdAppByManifestPathAnnotation
if useSHALabelForArgoDicovery {
f = findArgocdAppBySHA1Label
}
return f(ctx, componentPath, repo, appClient)
}

func SetArgoCDAppRevision(ctx context.Context, componentPath string, revision string, repo string, useSHALabelForArgoDicovery bool) error {
var foundApp *argoappv1.Application
var err error
ac, err := createArgoCdClients()
if err != nil {
return fmt.Errorf("Error creating ArgoCD clients: %w", err)
}
if useSHALabelForArgoDicovery {
foundApp, err = findArgocdAppBySHA1Label(ctx, componentPath, repo, ac.app)
} else {
foundApp, err = findArgocdAppByManifestPathAnnotation(ctx, componentPath, repo, ac.app)
}
foundApp, err = findArgocdApp(ctx, componentPath, repo, ac.app, useSHALabelForArgoDicovery)
if err != nil {
return fmt.Errorf("error finding ArgoCD application for component path %s: %w", componentPath, err)
}
Expand Down

0 comments on commit 779e66f

Please sign in to comment.