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.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.StringVar(&applyOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`)
|
||||
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
||||
if !runtime.V1Mode {
|
||||
// TODO: Remove this function once Helmfile v0.x
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
|||
}
|
||||
|
||||
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.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")
|
||||
|
|
|
|||
|
|
@ -1369,11 +1369,17 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
|||
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)
|
||||
if len(errs) > 0 {
|
||||
return false, false, errs
|
||||
}
|
||||
|
||||
helm.SetExtraArgs()
|
||||
|
||||
var toDelete []state.ReleaseSpec
|
||||
for _, r := range releasesToBeDeleted {
|
||||
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 {
|
||||
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
|
||||
|
||||
|
|
@ -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)
|
||||
|
||||
helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...)
|
||||
return errs
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -2215,6 +2215,7 @@ type applyConfig struct {
|
|||
stripTrailingCR bool
|
||||
interactive bool
|
||||
skipDiffOnInstall bool
|
||||
diffArgs string
|
||||
logger *zap.SugaredLogger
|
||||
wait bool
|
||||
waitForJobs bool
|
||||
|
|
@ -2348,6 +2349,10 @@ func (a applyConfig) SkipDiffOnInstall() bool {
|
|||
return a.skipDiffOnInstall
|
||||
}
|
||||
|
||||
func (a applyConfig) DiffArgs() string {
|
||||
return a.diffArgs
|
||||
}
|
||||
|
||||
// helmfile-template-only flags
|
||||
|
||||
func (a applyConfig) IncludeCRDs() bool {
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ type ApplyConfigProvider interface {
|
|||
SkipCleanup() bool
|
||||
SkipDiffOnInstall() bool
|
||||
|
||||
DiffArgs() string
|
||||
|
||||
DAGConfig
|
||||
|
||||
concurrencyConfig
|
||||
|
|
@ -130,6 +132,7 @@ type DiffConfigProvider interface {
|
|||
NoHooks() bool
|
||||
SuppressDiff() bool
|
||||
SkipDiffOnInstall() bool
|
||||
DiffArgs() string
|
||||
|
||||
DAGConfig
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
type diffConfig struct {
|
||||
args string
|
||||
diffArgs string
|
||||
values []string
|
||||
retainValuesFiles bool
|
||||
set []string
|
||||
|
|
@ -47,6 +48,10 @@ func (a diffConfig) Args() string {
|
|||
return a.args
|
||||
}
|
||||
|
||||
func (a diffConfig) DiffArgs() string {
|
||||
return a.diffArgs
|
||||
}
|
||||
|
||||
func (a diffConfig) Values() []string {
|
||||
return a.values
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ type ApplyOptions struct {
|
|||
IncludeTransitiveNeeds bool
|
||||
// SkipDiffOnInstall is true if the diff should be skipped on install
|
||||
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 bool
|
||||
// Suppress is true if the output should be suppressed
|
||||
|
|
@ -155,6 +157,11 @@ func (a *ApplyImpl) SkipDiffOnInstall() bool {
|
|||
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.
|
||||
func (a *ApplyImpl) SkipNeeds() bool {
|
||||
if !a.IncludeNeeds() {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ type DiffOptions struct {
|
|||
ResetValues bool
|
||||
// Propagate '--post-renderer' to helmv3 template and helm install
|
||||
PostRenderer string
|
||||
// DiffArgs is the list of arguments to pass to helm-diff.
|
||||
DiffArgs string
|
||||
}
|
||||
|
||||
// NewDiffOptions creates a new Apply
|
||||
|
|
@ -147,6 +149,11 @@ func (t *DiffImpl) SkipDiffOnInstall() bool {
|
|||
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
|
||||
func (t *DiffImpl) Suppress() []string {
|
||||
return t.DiffOptions.Suppress
|
||||
|
|
|
|||
|
|
@ -1910,6 +1910,7 @@ type DiffOpts struct {
|
|||
Set []string
|
||||
SkipCleanup bool
|
||||
SkipDiffOnInstall bool
|
||||
DiffArgs string
|
||||
ReuseValues bool
|
||||
ResetValues bool
|
||||
PostRenderer string
|
||||
|
|
|
|||
Loading…
Reference in New Issue