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

Override getContext operation for faster deployments #420

Merged
merged 1 commit into from
Mar 31, 2020
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 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 @@ -82,6 +83,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