From ea57c0e35ab997657f5742be031db98f5c14c938 Mon Sep 17 00:00:00 2001 From: Oded Ben Ozer Date: Mon, 1 Jul 2024 11:24:20 +0200 Subject: [PATCH] Linter issues --- internal/pkg/githubapi/github.go | 18 +++++++++++------- internal/pkg/githubapi/promotion.go | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/pkg/githubapi/github.go b/internal/pkg/githubapi/github.go index be62089..1b3ba77 100644 --- a/internal/pkg/githubapi/github.go +++ b/internal/pkg/githubapi/github.go @@ -586,18 +586,22 @@ func handleMergedPrEvent(ghPrClientDetails GhPrClientDetails, prApproverGithubCl if config.AllowSyncArgoCDAppfromBranchPathRegex != "" { componentPathList, err := generateListOfChangedComponentPaths(ghPrClientDetails, config) - for _, componentPath := range componentPathList { - if isSyncFromBranchAllowedForThisPath(config.AllowSyncArgoCDAppfromBranchPathRegex, componentPath) { - ghPrClientDetails.PrLogger.Errorf("Ensuring ArgoCD app %s is set to HEAD\n", componentPath) - err := argocd.SetArgoCDAppRevision(ghPrClientDetails.Ctx, componentPath, "HEAD", ghPrClientDetails.RepoURL, config.UseSHALabelForArgoDicovery) - if err != nil { - ghPrClientDetails.PrLogger.Errorf("Failed to set ArgoCD app %s, to HEAD: err=%s\n", err) + if err != nil { + ghPrClientDetails.PrLogger.Errorf("Failed to get list of changed components for setting ArgoCD app targetRef to HEAD: err=%s\n", err) + } else { + for _, componentPath := range componentPathList { + if isSyncFromBranchAllowedForThisPath(config.AllowSyncArgoCDAppfromBranchPathRegex, componentPath) { + ghPrClientDetails.PrLogger.Errorf("Ensuring ArgoCD app %s is set to HEAD\n", componentPath) + err := argocd.SetArgoCDAppRevision(ghPrClientDetails.Ctx, componentPath, "HEAD", ghPrClientDetails.RepoURL, config.UseSHALabelForArgoDicovery) + if err != nil { + ghPrClientDetails.PrLogger.Errorf("Failed to set ArgoCD app @ %s, to HEAD: err=%s\n", componentPath, err) + } } } } } - return nil + return err } // Creating a unique branch name based on the PR number, PR ref and the promotion target paths diff --git a/internal/pkg/githubapi/promotion.go b/internal/pkg/githubapi/promotion.go index 2bf73fd..d15a3f1 100644 --- a/internal/pkg/githubapi/promotion.go +++ b/internal/pkg/githubapi/promotion.go @@ -171,7 +171,6 @@ type relevantComponent struct { } func generateListOfChangedComponentPaths(ghPrClientDetails GhPrClientDetails, config *cfg.Config) (changedComponentPaths []string, err error) { - // If the PR has a list of promoted paths in the PR Telefonistika metadata(=is a promotion PR), we use that if len(ghPrClientDetails.PrMetadata.PromotedPaths) > 0 { changedComponentPaths = ghPrClientDetails.PrMetadata.PromotedPaths