fix conflicts

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2024-05-25 22:35:44 +08:00
parent 3f6c03999a
commit 279d7dee18
9 changed files with 33 additions and 0 deletions

View File

@ -70,6 +70,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.StringArrayVar(&applyOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`) f.StringArrayVar(&applyOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`)
f.StringVar(&applyOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") f.StringVar(&applyOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background")
f.StringArrayVar(&applyOptions.SuppressOutputLineRegex, "suppress-output-line-regex", nil, "a list of regex patterns to suppress output lines from the diff output") f.StringArrayVar(&applyOptions.SuppressOutputLineRegex, "suppress-output-line-regex", nil, "a list of regex patterns to suppress output lines from the diff output")
f.StringVar(&applyOptions.DryRyn, "dry-run", "", "pass dry-run to helm exec")
return cmd return cmd
} }

View File

@ -48,6 +48,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.StringVar(&syncOptions.PostRenderer, "post-renderer", "", `pass --post-renderer to "helm template" or "helm upgrade --install"`) f.StringVar(&syncOptions.PostRenderer, "post-renderer", "", `pass --post-renderer to "helm template" or "helm upgrade --install"`)
f.StringArrayVar(&syncOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`) f.StringArrayVar(&syncOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`)
f.StringVar(&syncOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") f.StringVar(&syncOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background")
f.StringVar(&syncOptions.DryRyn, "dry-run", "", "pass dry-run to helm exec")
return cmd return cmd
} }

View File

@ -1536,6 +1536,7 @@ Do you really want to apply?
PostRenderer: c.PostRenderer(), PostRenderer: c.PostRenderer(),
PostRendererArgs: c.PostRendererArgs(), PostRendererArgs: c.PostRendererArgs(),
SyncArgs: c.SyncArgs(), SyncArgs: c.SyncArgs(),
DryRun: c.DryRun(),
} }
return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), syncOpts) return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), syncOpts)
})) }))
@ -1929,6 +1930,7 @@ Do you really want to sync?
PostRenderer: c.PostRenderer(), PostRenderer: c.PostRenderer(),
PostRendererArgs: c.PostRendererArgs(), PostRendererArgs: c.PostRendererArgs(),
SyncArgs: c.SyncArgs(), SyncArgs: c.SyncArgs(),
DryRun: c.DryRun(),
} }
return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), opts) return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), opts)
})) }))

View File

@ -2196,6 +2196,7 @@ func (c configImpl) ShowOnly() []string {
type applyConfig struct { type applyConfig struct {
args string args string
cascade string cascade string
dryRun string
values []string values []string
// TODO: Remove this function once Helmfile v0.x // TODO: Remove this function once Helmfile v0.x
@ -2415,6 +2416,10 @@ func (a applyConfig) ShowOnly() []string {
return a.showOnly return a.showOnly
} }
func (a applyConfig) DryRun() string {
return a.dryRun
}
type depsConfig struct { type depsConfig struct {
skipRepos bool skipRepos bool
includeTransitiveNeeds bool includeTransitiveNeeds bool

View File

@ -52,6 +52,7 @@ type ApplyConfigProvider interface {
PostRendererArgs() []string PostRendererArgs() []string
Cascade() string Cascade() string
SuppressOutputLineRegex() []string SuppressOutputLineRegex() []string
DryRun() string
Values() []string Values() []string
Set() []string Set() []string
@ -99,6 +100,7 @@ type SyncConfigProvider interface {
PostRenderer() string PostRenderer() string
PostRendererArgs() []string PostRendererArgs() []string
Cascade() string Cascade() string
DryRun() string
Values() []string Values() []string
Set() []string Set() []string

View File

@ -66,6 +66,8 @@ type ApplyOptions struct {
SuppressOutputLineRegex []string SuppressOutputLineRegex []string
// SyncArgs is the list of arguments to pass to helm upgrade. // SyncArgs is the list of arguments to pass to helm upgrade.
SyncArgs string SyncArgs string
// DryRun is for helm dry-run flag
DryRyn string
} }
// NewApply creates a new Apply // NewApply creates a new Apply
@ -247,3 +249,8 @@ func (a *ApplyImpl) SuppressOutputLineRegex() []string {
func (a *ApplyImpl) SyncArgs() string { func (a *ApplyImpl) SyncArgs() string {
return a.ApplyOptions.SyncArgs return a.ApplyOptions.SyncArgs
} }
// DryRun returns dry-run flag
func (a *ApplyImpl) DryRun() string {
return a.ApplyOptions.DryRyn
}

View File

@ -34,6 +34,8 @@ type SyncOptions struct {
Cascade string Cascade string
// SyncArgs is the list of arguments to pass to the helm upgrade command. // SyncArgs is the list of arguments to pass to the helm upgrade command.
SyncArgs string SyncArgs string
// DryRun is for helm dry-run flag
DryRyn string
} }
// NewSyncOptions creates a new Apply // NewSyncOptions creates a new Apply
@ -139,3 +141,8 @@ func (t *SyncImpl) Cascade() string {
func (t *SyncImpl) SyncArgs() string { func (t *SyncImpl) SyncArgs() string {
return t.SyncOptions.SyncArgs return t.SyncOptions.SyncArgs
} }
// DryRun returns dry-run flag
func (t *SyncImpl) DryRun() string {
return t.SyncOptions.DryRyn
}

View File

@ -100,6 +100,12 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *
} }
return flags return flags
} }
func (st *HelmState) appendDryRunFlags(flags []string, opt *SyncOpts) []string {
if opt != nil && opt.DryRun != "" {
flags = append(flags, "--dry-run", opt.DryRun)
}
return flags
}
// append post-renderer flags to helm flags // append post-renderer flags to helm flags
func (st *HelmState) appendCascadeFlags(flags []string, helm helmexec.Interface, release *ReleaseSpec, cascade string) []string { func (st *HelmState) appendCascadeFlags(flags []string, helm helmexec.Interface, release *ReleaseSpec, cascade string) []string {

View File

@ -753,6 +753,7 @@ type SyncOpts struct {
PostRenderer string PostRenderer string
PostRendererArgs []string PostRendererArgs []string
SyncArgs string SyncArgs string
DryRun string
} }
type SyncOpt interface{ Apply(*SyncOpts) } type SyncOpt interface{ Apply(*SyncOpts) }
@ -2672,6 +2673,7 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
postRendererArgs = opt.PostRendererArgs postRendererArgs = opt.PostRendererArgs
} }
flags = st.appendPostRenderArgsFlags(flags, release, postRendererArgs) flags = st.appendPostRenderArgsFlags(flags, release, postRendererArgs)
flags = st.appendDryRunFlags(flags, opt)
flags = st.appendExtraSyncFlags(flags, opt) flags = st.appendExtraSyncFlags(flags, opt)