Implement --diff-args (#959)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
parent
ab50997798
commit
9bc7bfc500
|
|
@ -41,6 +41,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||||
f.StringVar(&applyOptions.Output, "output", "", "output format for diff plugin")
|
f.StringVar(&applyOptions.Output, "output", "", "output format for diff plugin")
|
||||||
f.BoolVar(&applyOptions.DetailedExitcode, "detailed-exitcode", false, "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully")
|
f.BoolVar(&applyOptions.DetailedExitcode, "detailed-exitcode", false, "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully")
|
||||||
f.BoolVar(&applyOptions.StripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
|
f.BoolVar(&applyOptions.StripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
|
||||||
|
f.StringVar(&applyOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`)
|
||||||
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
||||||
if !runtime.V1Mode {
|
if !runtime.V1Mode {
|
||||||
// TODO: Remove this function once Helmfile v0.x
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
f := cmd.Flags()
|
f := cmd.Flags()
|
||||||
|
f.StringVar(&diffOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`)
|
||||||
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm diff")
|
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm diff")
|
||||||
f.StringArrayVar(&diffOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag")
|
f.StringArrayVar(&diffOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag")
|
||||||
f.StringArrayVar(&diffOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag")
|
f.StringArrayVar(&diffOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag")
|
||||||
|
|
|
||||||
|
|
@ -1369,11 +1369,17 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
||||||
PostRenderer: c.PostRenderer(),
|
PostRenderer: c.PostRenderer(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// join --args and --diff-args together to one string.
|
||||||
|
args := strings.Join([]string{c.Args(), c.DiffArgs()}, " ")
|
||||||
|
helm.SetExtraArgs(argparser.GetArgs(args, r.state)...)
|
||||||
|
|
||||||
infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts)
|
infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts)
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return false, false, errs
|
return false, false, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helm.SetExtraArgs()
|
||||||
|
|
||||||
var toDelete []state.ReleaseSpec
|
var toDelete []state.ReleaseSpec
|
||||||
for _, r := range releasesToBeDeleted {
|
for _, r := range releasesToBeDeleted {
|
||||||
toDelete = append(toDelete, r)
|
toDelete = append(toDelete, r)
|
||||||
|
|
@ -1586,7 +1592,8 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
||||||
ok, errs := a.withNeeds(r, c, true, func(st *state.HelmState) []error {
|
ok, errs := a.withNeeds(r, c, true, func(st *state.HelmState) []error {
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
|
|
||||||
helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...)
|
args := strings.Join([]string{c.Args(), c.DiffArgs()}, " ")
|
||||||
|
helm.SetExtraArgs(argparser.GetArgs(args, r.state)...)
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
|
|
||||||
|
|
@ -1610,6 +1617,7 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error)
|
||||||
}
|
}
|
||||||
infoMsg, updated, deleted, errs = filtered.diff(true, c.DetailedExitcode(), c, opts)
|
infoMsg, updated, deleted, errs = filtered.diff(true, c.DetailedExitcode(), c, opts)
|
||||||
|
|
||||||
|
helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...)
|
||||||
return errs
|
return errs
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2215,6 +2215,7 @@ type applyConfig struct {
|
||||||
stripTrailingCR bool
|
stripTrailingCR bool
|
||||||
interactive bool
|
interactive bool
|
||||||
skipDiffOnInstall bool
|
skipDiffOnInstall bool
|
||||||
|
diffArgs string
|
||||||
logger *zap.SugaredLogger
|
logger *zap.SugaredLogger
|
||||||
wait bool
|
wait bool
|
||||||
waitForJobs bool
|
waitForJobs bool
|
||||||
|
|
@ -2348,6 +2349,10 @@ func (a applyConfig) SkipDiffOnInstall() bool {
|
||||||
return a.skipDiffOnInstall
|
return a.skipDiffOnInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a applyConfig) DiffArgs() string {
|
||||||
|
return a.diffArgs
|
||||||
|
}
|
||||||
|
|
||||||
// helmfile-template-only flags
|
// helmfile-template-only flags
|
||||||
|
|
||||||
func (a applyConfig) IncludeCRDs() bool {
|
func (a applyConfig) IncludeCRDs() bool {
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,8 @@ type ApplyConfigProvider interface {
|
||||||
SkipCleanup() bool
|
SkipCleanup() bool
|
||||||
SkipDiffOnInstall() bool
|
SkipDiffOnInstall() bool
|
||||||
|
|
||||||
|
DiffArgs() string
|
||||||
|
|
||||||
DAGConfig
|
DAGConfig
|
||||||
|
|
||||||
concurrencyConfig
|
concurrencyConfig
|
||||||
|
|
@ -130,6 +132,7 @@ type DiffConfigProvider interface {
|
||||||
NoHooks() bool
|
NoHooks() bool
|
||||||
SuppressDiff() bool
|
SuppressDiff() bool
|
||||||
SkipDiffOnInstall() bool
|
SkipDiffOnInstall() bool
|
||||||
|
DiffArgs() string
|
||||||
|
|
||||||
DAGConfig
|
DAGConfig
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import (
|
||||||
|
|
||||||
type diffConfig struct {
|
type diffConfig struct {
|
||||||
args string
|
args string
|
||||||
|
diffArgs string
|
||||||
values []string
|
values []string
|
||||||
retainValuesFiles bool
|
retainValuesFiles bool
|
||||||
set []string
|
set []string
|
||||||
|
|
@ -47,6 +48,10 @@ func (a diffConfig) Args() string {
|
||||||
return a.args
|
return a.args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a diffConfig) DiffArgs() string {
|
||||||
|
return a.diffArgs
|
||||||
|
}
|
||||||
|
|
||||||
func (a diffConfig) Values() []string {
|
func (a diffConfig) Values() []string {
|
||||||
return a.values
|
return a.values
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ type ApplyOptions struct {
|
||||||
IncludeTransitiveNeeds bool
|
IncludeTransitiveNeeds bool
|
||||||
// SkipDiffOnInstall is true if the diff should be skipped on install
|
// SkipDiffOnInstall is true if the diff should be skipped on install
|
||||||
SkipDiffOnInstall bool
|
SkipDiffOnInstall bool
|
||||||
|
// DiffArgs is the list of arguments to pass to the helm-diff.
|
||||||
|
DiffArgs string
|
||||||
// IncludeTests is true if the tests should be included
|
// IncludeTests is true if the tests should be included
|
||||||
IncludeTests bool
|
IncludeTests bool
|
||||||
// Suppress is true if the output should be suppressed
|
// Suppress is true if the output should be suppressed
|
||||||
|
|
@ -155,6 +157,11 @@ func (a *ApplyImpl) SkipDiffOnInstall() bool {
|
||||||
return a.ApplyOptions.SkipDiffOnInstall
|
return a.ApplyOptions.SkipDiffOnInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiffArgs is the list of arguments to pass to helm-diff.
|
||||||
|
func (a *ApplyImpl) DiffArgs() string {
|
||||||
|
return a.ApplyOptions.DiffArgs
|
||||||
|
}
|
||||||
|
|
||||||
// SkipNeeds returns the skip needs.
|
// SkipNeeds returns the skip needs.
|
||||||
func (a *ApplyImpl) SkipNeeds() bool {
|
func (a *ApplyImpl) SkipNeeds() bool {
|
||||||
if !a.IncludeNeeds() {
|
if !a.IncludeNeeds() {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ type DiffOptions struct {
|
||||||
ResetValues bool
|
ResetValues bool
|
||||||
// Propagate '--post-renderer' to helmv3 template and helm install
|
// Propagate '--post-renderer' to helmv3 template and helm install
|
||||||
PostRenderer string
|
PostRenderer string
|
||||||
|
// DiffArgs is the list of arguments to pass to helm-diff.
|
||||||
|
DiffArgs string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDiffOptions creates a new Apply
|
// NewDiffOptions creates a new Apply
|
||||||
|
|
@ -147,6 +149,11 @@ func (t *DiffImpl) SkipDiffOnInstall() bool {
|
||||||
return t.DiffOptions.SkipDiffOnInstall
|
return t.DiffOptions.SkipDiffOnInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiffArgs returns the list of arguments to pass to helm-diff.
|
||||||
|
func (t *DiffImpl) DiffArgs() string {
|
||||||
|
return t.DiffOptions.DiffArgs
|
||||||
|
}
|
||||||
|
|
||||||
// Suppress returns the suppress
|
// Suppress returns the suppress
|
||||||
func (t *DiffImpl) Suppress() []string {
|
func (t *DiffImpl) Suppress() []string {
|
||||||
return t.DiffOptions.Suppress
|
return t.DiffOptions.Suppress
|
||||||
|
|
|
||||||
|
|
@ -1910,6 +1910,7 @@ type DiffOpts struct {
|
||||||
Set []string
|
Set []string
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
SkipDiffOnInstall bool
|
SkipDiffOnInstall bool
|
||||||
|
DiffArgs string
|
||||||
ReuseValues bool
|
ReuseValues bool
|
||||||
ResetValues bool
|
ResetValues bool
|
||||||
PostRenderer string
|
PostRenderer string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue