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

feat(#502): display summary of upgraded, deleted and error releases #560

Merged
merged 3 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
working_directory: /go/src/github.com/roboll/helmfile
steps:
- checkout
- run: make dep
- run: make build
- persist_to_workspace:
root: /go/src/github.com/roboll/helmfile
Expand All @@ -20,6 +21,7 @@ jobs:
working_directory: /go/src/github.com/roboll/helmfile
steps:
- checkout
- run: make dep
- run: make check
- run: make pristine
- run: make test
Expand Down
17 changes: 17 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
[[constraint]]
name = "github.com/imdario/mergo"
version = "0.3.6"

[[constraint]]
name = "github.com/tatsushid/go-prettytable"
branch= "master"
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
ORG ?= $(shell basename $(realpath ..))
PKGS := $(shell go list ./... | grep -v /vendor/)

build:
go build ${TARGETS}
dep: ## Get build dependencies
go get -v -u github.com/golang/dep/cmd/dep
sgandon marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: dep

build: ## Build the app after getting all dependencies (make sure to call make dep before)
dep ensure && go build ${TARGETS}
.PHONY: build

generate:
Expand All @@ -14,7 +18,7 @@ fmt:
.PHONY: fmt

check:
go vet ${PKGS}
dep ensure && go vet ${PKGS}
.PHONY: check

test:
Expand Down Expand Up @@ -43,7 +47,7 @@ clean:

pristine: generate fmt
git diff | cat
git ls-files --exclude-standard --modified --deleted --others | diff /dev/null -
git ls-files --exclude-standard --modified --deleted --others -x vendor | diff /dev/null -
.PHONY: pristine

release: pristine cross
Expand Down
45 changes: 30 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ func main() {
},
},
Action: func(c *cli.Context) error {
return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
return executeSyncCommand(c, state, helm)
affectedReleases := state.AffectedReleases{}
errs := findAndIterateOverDesiredStatesUsingFlags(c, func(st *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
return executeSyncCommand(c, &affectedReleases, st, helm)
})
affectedReleases.DisplayAffectedReleases(c.App.Metadata["logger"].(*zap.SugaredLogger))
return errs
},
},
{
Expand Down Expand Up @@ -288,20 +291,23 @@ func main() {
},
},
Action: func(c *cli.Context) error {
return findAndIterateOverDesiredStatesUsingFlags(c, func(state *state.HelmState, helm helmexec.Interface, ctx app.Context) []error {
affectedReleases := state.AffectedReleases{}
errs := findAndIterateOverDesiredStatesUsingFlags(c, func(st *state.HelmState, helm helmexec.Interface, ctx app.Context) []error {
if !c.Bool("skip-deps") {
if errs := ctx.SyncReposOnce(state, helm); errs != nil && len(errs) > 0 {
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
return errs
}
if errs := state.BuildDeps(helm); errs != nil && len(errs) > 0 {
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
sgandon marked this conversation as resolved.
Show resolved Hide resolved
return errs
}
}
if errs := state.PrepareRelease(helm, "sync"); errs != nil && len(errs) > 0 {
if errs := st.PrepareRelease(helm, "sync"); errs != nil && len(errs) > 0 {
return errs
}
return executeSyncCommand(c, state, helm)
return executeSyncCommand(c, &affectedReleases, st, helm)
})
affectedReleases.DisplayAffectedReleases(c.App.Metadata["logger"].(*zap.SugaredLogger))
return errs
},
},
{
Expand Down Expand Up @@ -332,7 +338,8 @@ func main() {
},
},
Action: func(c *cli.Context) error {
return findAndIterateOverDesiredStatesUsingFlags(c, func(st *state.HelmState, helm helmexec.Interface, ctx app.Context) []error {
affectedReleases := state.AffectedReleases{}
errs := findAndIterateOverDesiredStatesUsingFlags(c, func(st *state.HelmState, helm helmexec.Interface, ctx app.Context) []error {
if !c.Bool("skip-deps") {
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
return errs
Expand Down Expand Up @@ -396,13 +403,15 @@ Do you really want to apply?
}

st.Releases = rs
return executeSyncCommand(c, st, helm)
return executeSyncCommand(c, &affectedReleases, st, helm)
}
}
}

return errs
})
affectedReleases.DisplayAffectedReleases(c.App.Metadata["logger"].(*zap.SugaredLogger))
return errs
},
},
{
Expand Down Expand Up @@ -448,7 +457,8 @@ Do you really want to apply?
},
},
Action: func(c *cli.Context) error {
return cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
affectedReleases := state.AffectedReleases{}
errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
purge := c.Bool("purge")

args := args.GetArgs(c.String("args"), state)
Expand All @@ -470,10 +480,12 @@ Do you really want to delete?
`, strings.Join(names, "\n"))
interactive := c.GlobalBool("interactive")
if !interactive || interactive && askForConfirmation(msg) {
return state.DeleteReleases(helm, purge)
return state.DeleteReleases(&affectedReleases, helm, purge)
}
return nil
})
affectedReleases.DisplayAffectedReleases(c.App.Metadata["logger"].(*zap.SugaredLogger))
return errs
},
},
{
Expand All @@ -487,7 +499,8 @@ Do you really want to delete?
},
},
Action: func(c *cli.Context) error {
return cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
affectedReleases := state.AffectedReleases{}
errs := cmd.FindAndIterateOverDesiredStatesUsingFlagsWithReverse(c, true, func(state *state.HelmState, helm helmexec.Interface, _ app.Context) []error {
args := args.GetArgs(c.String("args"), state)
if len(args) > 0 {
helm.SetExtraArgs(args...)
Expand All @@ -507,10 +520,12 @@ Do you really want to delete?
`, strings.Join(names, "\n"))
interactive := c.GlobalBool("interactive")
if !interactive || interactive && askForConfirmation(msg) {
return state.DeleteReleases(helm, true)
return state.DeleteReleases(&affectedReleases, helm, true)
}
return nil
})
affectedReleases.DisplayAffectedReleases(c.App.Metadata["logger"].(*zap.SugaredLogger))
sgandon marked this conversation as resolved.
Show resolved Hide resolved
return errs
},
},
{
Expand Down Expand Up @@ -561,7 +576,7 @@ Do you really want to delete?
}
}

func executeSyncCommand(c *cli.Context, state *state.HelmState, helm helmexec.Interface) []error {
func executeSyncCommand(c *cli.Context, affectedReleases *state.AffectedReleases, state *state.HelmState, helm helmexec.Interface) []error {
args := args.GetArgs(c.String("args"), state)
if len(args) > 0 {
helm.SetExtraArgs(args...)
Expand All @@ -570,7 +585,7 @@ func executeSyncCommand(c *cli.Context, state *state.HelmState, helm helmexec.In
values := c.StringSlice("values")
workers := c.Int("concurrency")

return state.SyncReleases(helm, values, workers)
return state.SyncReleases(affectedReleases, helm, values, workers)
}

func executeTemplateCommand(c *cli.Context, state *state.HelmState, helm helmexec.Interface) []error {
Expand Down
9 changes: 5 additions & 4 deletions state/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package state
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

"github.com/imdario/mergo"
"github.com/roboll/helmfile/environment"
"github.com/roboll/helmfile/helmexec"
"github.com/roboll/helmfile/tmpl"
"go.uber.org/zap"
"gopkg.in/yaml.v2"
"io"
"io/ioutil"
"os"
"path/filepath"
)

type StateLoadError struct {
Expand Down
Loading