From 7d7a9b86b7b4a517f00ad7ba8d731be623b30542 Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Fri, 31 Jul 2020 16:53:56 +0000 Subject: [PATCH] Fix generic kustomize error during kots pull release --- kotsadm/pkg/downstream/diff.go | 5 ++--- kotsadm/pkg/gitops/gitops.go | 13 ++++++------- kotsadm/pkg/handlers/rendered_contents.go | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/kotsadm/pkg/downstream/diff.go b/kotsadm/pkg/downstream/diff.go index f5e879da59..c9bab4bf7f 100644 --- a/kotsadm/pkg/downstream/diff.go +++ b/kotsadm/pkg/downstream/diff.go @@ -10,7 +10,6 @@ import ( "github.com/marccampbell/yaml-toolbox/pkg/splitter" "github.com/pkg/errors" - "github.com/replicatedhq/kots/kotsadm/pkg/logger" "github.com/sergi/go-diff/diffmatchpatch" ) @@ -52,14 +51,14 @@ func DiffAppVersionsForDownstream(downstreamName string, archive string, diffBas archiveOutput, err := exec.Command(fmt.Sprintf("kustomize%s", kustomizeVersion), "build", filepath.Join(archive, "overlays", "downstreams", downstreamName)).Output() if err != nil { if ee, ok := err.(*exec.ExitError); ok { - logger.Errorf("kustomize stderr: %q", string(ee.Stderr)) + err = fmt.Errorf("kustomize stderr: %q", string(ee.Stderr)) } return nil, errors.Wrap(err, "failed to run kustomize on archive dir") } baseOutput, err := exec.Command(fmt.Sprintf("kustomize%s", kustomizeVersion), "build", filepath.Join(diffBasePath, "overlays", "downstreams", downstreamName)).Output() if err != nil { if ee, ok := err.(*exec.ExitError); ok { - logger.Errorf("kustomize stderr: %q", string(ee.Stderr)) + err = fmt.Errorf("kustomize stderr: %q", string(ee.Stderr)) } return nil, errors.Wrap(err, "failed to run kustomize on base dir") } diff --git a/kotsadm/pkg/gitops/gitops.go b/kotsadm/pkg/gitops/gitops.go index 1dba47285b..1eaa6c4ba8 100644 --- a/kotsadm/pkg/gitops/gitops.go +++ b/kotsadm/pkg/gitops/gitops.go @@ -15,7 +15,6 @@ import ( "github.com/pkg/errors" "github.com/replicatedhq/kots/kotsadm/pkg/kotsutil" - "github.com/replicatedhq/kots/kotsadm/pkg/logger" "github.com/replicatedhq/kots/pkg/crypto" "golang.org/x/crypto/ssh" "gopkg.in/src-d/go-git.v4" @@ -225,11 +224,11 @@ func UpdateDownstreamGitOps(appID, clusterID, uri, branch, path, format, action appKey := fmt.Sprintf("%s-%s", appID, clusterID) newAppData := map[string]string{ - "repoUri": uri, - "branch": branch, - "path": path, - "format": format, - "action": action, + "repoUri": uri, + "branch": branch, + "path": path, + "format": format, + "action": action, } // check if to reset or keep last error @@ -326,7 +325,7 @@ func CreateGitOpsCommit(gitOpsConfig *GitOpsConfig, appSlug string, appName stri out, err := cmd.Output() if err != nil { if ee, ok := err.(*exec.ExitError); ok { - logger.Errorf("kustomize stderr: %q", string(ee.Stderr)) + err = fmt.Errorf("kustomize stderr: %q", string(ee.Stderr)) } return "", errors.Wrap(err, "failed to run kustomize") } diff --git a/kotsadm/pkg/handlers/rendered_contents.go b/kotsadm/pkg/handlers/rendered_contents.go index 3329fa7bd5..ba70434184 100644 --- a/kotsadm/pkg/handlers/rendered_contents.go +++ b/kotsadm/pkg/handlers/rendered_contents.go @@ -87,7 +87,7 @@ func GetAppRenderedContents(w http.ResponseWriter, r *http.Request) { archiveOutput, err := exec.Command(fmt.Sprintf("kustomize%s", kotsKinds.KustomizeVersion()), "build", kustomizeBuildTarget).Output() if err != nil { if ee, ok := err.(*exec.ExitError); ok { - logger.Errorf("kustomize stderr: %q", string(ee.Stderr)) + err = fmt.Errorf("kustomize stderr: %q", string(ee.Stderr)) } logger.Error(err) w.WriteHeader(500)