Repository: roboll/helmfile
Pull request #566 (2019-04-25 21:09:14)

fix(struct): renamed Error struct field into Failed
as @mumoshu suggested I have renamed the AffectedReleases.Error field to AffectedReleases.Failed to be more homogeneous with the other fields and to avoir conflits with other Error references.


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 9f0726b..e8753fd 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -4,24 +4,37 @@ jobs:
 
   build:
     docker:
-      - image: circleci/golang:1.12.1
-    working_directory: /go/src/github.com/roboll/helmfile
+      - image: circleci/golang:1.12.4
+    environment:
+      GOPATH: /go
     steps:
       - checkout
-      - run: make dep
+      - restore_cache:
+          keys:
+          - go-mod-cache-v1-{{ checksum "./go.sum" }}
+          - go-mod-cache-v1-
+      - run: go env
       - run: make build
+      - save_cache:
+          key: go-mod-cache-v1-{{ checksum "./go.sum" }}
+          paths:
+          - /go/pkg/mod
       - persist_to_workspace:
-          root: /go/src/github.com/roboll/helmfile
+          root: ./
           paths:
             - .
 
   test:
+    environment:
+      GOPATH: /go
     docker:
-      - image: circleci/golang:1.12.1
-    working_directory: /go/src/github.com/roboll/helmfile
+      - image: circleci/golang:1.12.4
     steps:
       - checkout
-      - run: make dep
+      - restore_cache:
+          keys:
+          - go-mod-cache-v1-{{ checksum "./go.sum" }}
+          - go-mod-cache-v1-
       - run: make check
       - run: make pristine
       - run: make test
diff --git a/Gopkg.lock b/Gopkg.lock
deleted file mode 100644
index cbbcced..0000000
--- a/Gopkg.lock
+++ /dev/null
@@ -1,138 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
-  digest = "1:d9141c149f722217d35834972878499a4781fe5ae46a152e8ac843ff15efc80f"
-  name = "github.com/Masterminds/semver"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "8d82589cda2d7b5b9167396841975c4535c9bec6"
-  version = "v1.4.1"
-
-[[projects]]
-  digest = "1:46a054a232ea2b7f0a35398d682b433d26ba9975fce9197b1784824402059f5b"
-  name = "github.com/Masterminds/sprig"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "6b2a58267f6a8b1dc8e2eb5519b984008fa85e8c"
-  version = "v2.15.0"
-
-[[projects]]
-  digest = "1:8f5416c7f59da8600725ae1ff00a99af1da8b04c211ae6f3c8f8bcab0164f650"
-  name = "github.com/aokoli/goutils"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "3391d3790d23d03408670993e957e8f408993c34"
-  version = "v1.0.1"
-
-[[projects]]
-  digest = "1:8f8811f9be822914c3a25c6a071e93beb4c805d7b026cbf298bc577bc1cc945b"
-  name = "github.com/google/uuid"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "064e2069ce9c359c118179501254f67d7d37ba24"
-  version = "0.2"
-
-[[projects]]
-  digest = "1:6b1e7618931d0ed9a17fec1c1d84271907aa61172c50b8272327f6cd4fafb650"
-  name = "github.com/huandu/xstrings"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "2bf18b218c51864a87384c06996e40ff9dcff8e1"
-  version = "v1.0.0"
-
-[[projects]]
-  digest = "1:8eb1de8112c9924d59bf1d3e5c26f5eaa2bfc2a5fcbb92dc1c2e4546d695f277"
-  name = "github.com/imdario/mergo"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4"
-  version = "v0.3.6"
-
-[[projects]]
-  digest = "1:0356f3312c9bd1cbeda81505b7fd437501d8e778ab66998ef69f00d7f9b3a0d7"
-  name = "github.com/mattn/go-runewidth"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "3ee7d812e62a0804a7d0a324e0249ca2db3476d3"
-  version = "v0.0.4"
-
-[[projects]]
-  branch = "master"
-  digest = "1:2b5df738fc5f371a46af628aea7aa7e4a62cff303087a5d7058dfc5f84a4a62c"
-  name = "github.com/tatsushid/go-prettytable"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "ed2d14c2993972f5ff95f34f17e6ce81b962779a"
-
-[[projects]]
-  digest = "1:55d0f7127962b0657acfd69650634057b3a08958226feee1b64a379666bb915e"
-  name = "github.com/urfave/cli"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "6011f165dc288c72abd8acd7722f837c5c64198d"
-
-[[projects]]
-  digest = "1:3c1a69cdae3501bf75e76d0d86dc6f2b0a7421bc205c0cb7b96b19eed464a34d"
-  name = "go.uber.org/atomic"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "1ea20fb1cbb1cc08cbd0d913a96dead89aa18289"
-  version = "v1.3.2"
-
-[[projects]]
-  digest = "1:60bf2a5e347af463c42ed31a493d817f8a72f102543060ed992754e689805d1a"
-  name = "go.uber.org/multierr"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "3c4937480c32f4c13a875a1829af76c98ca3d40a"
-  version = "v1.1.0"
-
-[[projects]]
-  digest = "1:9580b1b079114140ade8cec957685344d14f00119e0241f6b369633cb346eeb3"
-  name = "go.uber.org/zap"
-  packages = [
-    ".",
-    "buffer",
-    "internal/bufferpool",
-    "internal/color",
-    "internal/exit",
-    "zapcore",
-  ]
-  pruneopts = "UT"
-  revision = "eeedf312bc6c57391d84767a4cd413f02a917974"
-  version = "v1.8.0"
-
-[[projects]]
-  branch = "master"
-  digest = "1:7b1c378a71f617ec07229a1fcbb90b6a5344295823e1d732398f50fd9ae4bbec"
-  name = "golang.org/x/crypto"
-  packages = [
-    "pbkdf2",
-    "scrypt",
-  ]
-  pruneopts = "UT"
-  revision = "b2aa35443fbc700ab74c586ae79b81c171851023"
-
-[[projects]]
-  branch = "v2"
-  digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
-  name = "gopkg.in/yaml.v2"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
-
-[solve-meta]
-  analyzer-name = "dep"
-  analyzer-version = 1
-  input-imports = [
-    "github.com/Masterminds/sprig",
-    "github.com/imdario/mergo",
-    "github.com/tatsushid/go-prettytable",
-    "github.com/urfave/cli",
-    "go.uber.org/zap",
-    "go.uber.org/zap/zapcore",
-    "gopkg.in/yaml.v2",
-  ]
-  solver-name = "gps-cdcl"
-  solver-version = 1
diff --git a/Gopkg.toml b/Gopkg.toml
deleted file mode 100644
index a05c056..0000000
--- a/Gopkg.toml
+++ /dev/null
@@ -1,19 +0,0 @@
-[[constraint]]
-  name = "github.com/Masterminds/sprig"
-  version = "2.15.0"
-
-[[constraint]]
-  branch = "v2"
-  name = "gopkg.in/yaml.v2"
-
-[prune]
-  go-tests = true
-  unused-packages = true
-
-[[constraint]]
-  name = "github.com/imdario/mergo"
-  version = "0.3.6"
-
-[[constraint]]
-  name = "github.com/tatsushid/go-prettytable"
-  branch= "master"
\ No newline at end of file
diff --git a/Makefile b/Makefile
index a35c894..80d60ab 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,8 @@
 ORG     ?= $(shell basename $(realpath ..))
 PKGS    := $(shell go list ./... | grep -v /vendor/)
 
-dep: ## Get build dependencies
-	go get -v -u github.com/golang/dep/cmd/dep
-.PHONY: dep		
-
-build: ## Build the app after getting all dependencies (make sure to call make dep before)
-	dep ensure && go build ${TARGETS}
+build:
+	go build ${TARGETS}
 .PHONY: build
 
 generate:
@@ -18,7 +14,7 @@ fmt:
 .PHONY: fmt
 
 check:
-	dep ensure && go vet ${PKGS}
+	go vet ${PKGS}
 .PHONY: check
 
 test:
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..fd384f2
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,20 @@
+module github.com/roboll/helmfile
+
+go 1.12
+
+require (
+	github.com/Masterminds/semver v1.4.1
+	github.com/Masterminds/sprig v2.15.0+incompatible
+	github.com/aokoli/goutils v1.0.1
+	github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c
+	github.com/huandu/xstrings v1.0.0
+	github.com/imdario/mergo v0.3.6
+	github.com/mattn/go-runewidth v0.0.4
+	github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939
+	github.com/urfave/cli v0.0.0-20160620154522-6011f165dc28
+	go.uber.org/atomic v1.3.2
+	go.uber.org/multierr v1.1.0
+	go.uber.org/zap v1.8.0
+	golang.org/x/crypto v0.0.0-20180403160946-b2aa35443fbc
+	gopkg.in/yaml.v2 v2.2.1
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..0e4036e
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,29 @@
+github.com/Masterminds/semver v1.4.1 h1:CaDA1wAoM3rj9sAFyyZP37LloExUzxFGYt+DqJ870JA=
+github.com/Masterminds/semver v1.4.1/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
+github.com/Masterminds/sprig v2.15.0+incompatible h1:0gSxPGWS9PAr7U2NsQ2YQg6juRDINkUyuvbb4b2Xm8w=
+github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
+github.com/aokoli/goutils v1.0.1 h1:7fpzNGoJ3VA8qcrm++XEE1QUe0mIwNeLa02Nwq7RDkg=
+github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
+github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c h1:jWtZjFEUE/Bz0IeIhqCnyZ3HG6KRXSntXe4SjtuTH7c=
+github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/huandu/xstrings v1.0.0 h1:pO2K/gKgKaat5LdpAhxhluX2GPQMaI3W5FUz/I/UnWk=
+github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo=
+github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
+github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
+github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
+github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 h1:BhIUXV2ySTLrKgh/Hnts+QTQlIbWtomXt3LMdzME0A0=
+github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939/go.mod h1:omGxs4/6hNjxPKUTjmaNkPzehSnNJOJN6pMEbrlYIT4=
+github.com/urfave/cli v0.0.0-20160620154522-6011f165dc28 h1:Yf7/DcGM+61oLBGXQV2Q+ztEGBcOe3EUnbKSOn4fQuE=
+github.com/urfave/cli v0.0.0-20160620154522-6011f165dc28/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
+go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
+go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.8.0 h1:r6Za1Rii8+EGOYRDLvpooNOF6kP3iyDnkpzbw67gCQ8=
+go.uber.org/zap v1.8.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20180403160946-b2aa35443fbc h1:Kx1Ke+iCR1aDjbWXgmEQGFxoHtNL49aRZGV7/+jJ41Y=
+golang.org/x/crypto v0.0.0-20180403160946-b2aa35443fbc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/state/state.go b/state/state.go
index 9b1525f..8b254c8 100644
--- a/state/state.go
+++ b/state/state.go
@@ -157,7 +157,7 @@ type SetValue struct {
 type AffectedReleases struct {
 	Upgraded []*ReleaseSpec
 	Deleted  []*ReleaseSpec
-	Error    []*ReleaseSpec
+	Failed   []*ReleaseSpec
 }
 
 const DefaultEnv = "default"
@@ -346,14 +346,14 @@ func (st *HelmState) SyncReleases(affectedReleases *AffectedReleases, helm helme
 						relErr = &ReleaseError{release, err}
 					} else if installed {
 						if err := helm.DeleteRelease(context, release.Name, "--purge"); err != nil {
-							affectedReleases.Error = append(affectedReleases.Error, release)
+							affectedReleases.Failed = append(affectedReleases.Failed, release)
 							relErr = &ReleaseError{release, err}
 						} else {
 							affectedReleases.Deleted = append(affectedReleases.Deleted, release)
 						}
 					}
 				} else if err := helm.SyncRelease(context, release.Name, chart, flags...); err != nil {
-					affectedReleases.Error = append(affectedReleases.Error, release)
+					affectedReleases.Failed = append(affectedReleases.Failed, release)
 					relErr = &ReleaseError{release, err}
 				} else {
 					affectedReleases.Upgraded = append(affectedReleases.Upgraded, release)
@@ -816,7 +816,7 @@ func (st *HelmState) DeleteReleases(affectedReleases *AffectedReleases, helm hel
 		}
 		if installed {
 			if err := helm.DeleteRelease(context, release.Name, flags...); err != nil {
-				affectedReleases.Error = append(affectedReleases.Error, &release)
+				affectedReleases.Failed = append(affectedReleases.Failed, &release)
 				return err
 			} else {
 				affectedReleases.Deleted = append(affectedReleases.Deleted, &release)
@@ -1373,10 +1373,10 @@ func (ar *AffectedReleases) DisplayAffectedReleases(logger *zap.SugaredLogger) {
 			logger.Info(release.Name)
 		}
 	}
-	if ar.Error != nil {
+	if ar.Failed != nil {
 		logger.Info("\nList of releases in error :")
 		logger.Info("RELEASE")
-		for _, release := range ar.Error {
+		for _, release := range ar.Failed {
 			logger.Info(release.Name)
 		}
 	}


Test patch:
diff --git a/state/state_test.go b/state/state_test.go
index 74a1844..61587e4 100644
--- a/state/state_test.go
+++ b/state/state_test.go
@@ -653,7 +653,7 @@ type mockRelease struct {
 type mockAffected struct {
 	upgraded []*mockRelease
 	deleted  []*mockRelease
-	error    []*mockRelease
+	failed   []*mockRelease
 }
 
 func (helm *mockHelmExec) UpdateDeps(chart string) error {
@@ -1007,8 +1007,8 @@ func TestHelmState_SyncReleasesAffectedRealeases(t *testing.T) {
 
 			affectedReleases := AffectedReleases{}
 			if err := state.SyncReleases(&affectedReleases, helm, []string{}, 1); err != nil {
-				if !testEq(affectedReleases.Error, tt.wantAffected.error) {
-					t.Errorf("HelmState.SynchAffectedRelease() error failed for [%s] = %v, want %v", tt.name, affectedReleases.Error, tt.wantAffected.error)
+				if !testEq(affectedReleases.Failed, tt.wantAffected.failed) {
+					t.Errorf("HelmState.SynchAffectedRelease() error failed for [%s] = %v, want %v", tt.name, affectedReleases.Failed, tt.wantAffected.failed)
 				} //else expected error
 			}
 			if !testEq(affectedReleases.Upgraded, tt.wantAffected.upgraded) {
@@ -1776,7 +1776,7 @@ func TestHelmState_Delete(t *testing.T) {
 			affectedReleases := AffectedReleases{}
 			errs := state.DeleteReleases(&affectedReleases, helm, tt.purge)
 			if errs != nil {
-				if !tt.wantErr || len(affectedReleases.Error) != 1 || affectedReleases.Error[0].Name != release.Name {
+				if !tt.wantErr || len(affectedReleases.Failed) != 1 || affectedReleases.Failed[0].Name != release.Name {
 					t.Errorf("DeleteReleases() for %s error = %v, wantErr %v", tt.name, errs, tt.wantErr)
 					return
 				}