Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logs for ArgoCD API interaction #5

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
argoio "github.com/argoproj/argo-cd/v2/util/io"
"github.com/argoproj/gitops-engine/pkg/sync/hook"
"github.com/google/go-cmp/cmp"
log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

Expand Down Expand Up @@ -185,13 +186,15 @@ func generateDiffOfAComponent(ctx context.Context, componentPath string, prBranc
app, err := appIf.Get(ctx, &appNameQuery)
if err != nil {
componentDiffResult.DiffError = err
log.Errorf("Error getting app %s: %v", foundApps.Items[0].Name, err)
return componentDiffResult
}
componentDiffResult.ArgoCdAppName = app.Name
componentDiffResult.ArgoCdAppURL = fmt.Sprintf("%s/applications/%s", argoSettings.URL, app.Name)
resources, err := appIf.ManagedResources(ctx, &application.ResourcesQuery{ApplicationName: &app.Name, AppNamespace: &app.Namespace})
if err != nil {
componentDiffResult.DiffError = err
log.Errorf("Error getting (live)resources for app %s: %v", app.Name, err)
return componentDiffResult
}

Expand All @@ -206,6 +209,7 @@ func generateDiffOfAComponent(ctx context.Context, componentPath string, prBranc
manifests, err := appIf.GetManifests(ctx, &manifestQuery)
if err != nil {
componentDiffResult.DiffError = err
log.Errorf("Error getting manifests for app %s, revision %s: %v", app.Name, prBranch, err)
return componentDiffResult
}
diffOption.res = manifests
Expand All @@ -215,6 +219,7 @@ func generateDiffOfAComponent(ctx context.Context, componentPath string, prBranc
detailedProject, err := projIf.GetDetailedProject(ctx, &projectpkg.ProjectQuery{Name: app.Spec.Project})
if err != nil {
componentDiffResult.DiffError = err
log.Errorf("Error getting project %s: %v", app.Spec.Project, err)
return componentDiffResult
}

Expand Down Expand Up @@ -262,6 +267,7 @@ func GenerateDiffOfChangedComponents(ctx context.Context, componentPathList []st
currentDiffResult := generateDiffOfAComponent(ctx, componentPath, prBranch, repo, appIf, projIf, argoSettings)
if currentDiffResult.DiffError != nil {
hasComponentDiffErrors = true
err = currentDiffResult.DiffError
}
if currentDiffResult.HasDiff {
hasComponentDiff = true
Expand Down
Loading