Skip to content

Commit

Permalink
Merge pull request #420 from seb4stien/override_context
Browse files Browse the repository at this point in the history
Override getContext operation for faster deployments
  • Loading branch information
luisdavim authored Mar 31, 2020
2 parents f24bc76 + 80c3dd5 commit 5811b11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type cli struct {
noFancy bool
noNs bool
nsOverride string
contextOverride string
skipValidation bool
keepUntrackedReleases bool
showDiff bool
Expand Down Expand Up @@ -83,6 +84,7 @@ func (c *cli) parse() {
flag.IntVar(&c.diffContext, "diff-context", -1, "number of lines of context to show around changes in helm diff output")
flag.StringVar(&c.kubeconfig, "kubeconfig", "", "path to the kubeconfig file to use for CLI requests")
flag.StringVar(&c.nsOverride, "ns-override", "", "override defined namespaces with this one")
flag.StringVar(&c.contextOverride, "context-override", "", "override releases context with this one")
flag.BoolVar(&c.apply, "apply", false, "apply the plan directly")
flag.BoolVar(&c.dryRun, "dry-run", false, "apply the dry-run option for helm commands.")
flag.BoolVar(&c.destroy, "destroy", false, "delete all deployed releases.")
Expand Down
9 changes: 7 additions & 2 deletions internal/app/decision_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ func buildState(s *state) *currentState {
// release
<-sem
}()
r.HelmsmanContext = getReleaseContext(r.Name, r.Namespace)
if flags.contextOverride == "" {
r.HelmsmanContext = getReleaseContext(r.Name, r.Namespace)
} else {
log.Info("Overriding Helmsman context for " + r.Name + " as " + flags.contextOverride)
r.HelmsmanContext = flags.contextOverride
}
cs.releases[r.key()] = r
}(r)
}
Expand Down Expand Up @@ -126,7 +131,7 @@ func (cs *currentState) decide(r *release, s *state, p *plan) {
"you remove its protection.", r.Priority, noop)
}
} else if ok := cs.releaseExists(r, helmStatusPending); ok {
log.Error("Release [ "+r.Name+" ] in namespace [ "+r.Namespace+" ] is in pending-upgrade state. " +
log.Error("Release [ " + r.Name + " ] in namespace [ " + r.Namespace + " ] is in pending-upgrade state. " +
"This means application is being upgraded outside of this Helmsman invocation's scope." +
"Exiting, as this may cause issues when continuing...")
os.Exit(1)
Expand Down

0 comments on commit 5811b11

Please sign in to comment.