From 279d7dee1838a50fb73a1a5688f07ea275939840 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sat, 25 May 2024 22:35:44 +0800 Subject: [PATCH] fix conflicts Signed-off-by: yxxhero --- cmd/apply.go | 1 + cmd/sync.go | 1 + pkg/app/app.go | 2 ++ pkg/app/app_test.go | 5 +++++ pkg/app/config.go | 2 ++ pkg/config/apply.go | 7 +++++++ pkg/config/sync.go | 7 +++++++ pkg/state/helmx.go | 6 ++++++ pkg/state/state.go | 2 ++ 9 files changed, 33 insertions(+) diff --git a/cmd/apply.go b/cmd/apply.go index d2add4b3..91ec96a0 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -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.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.StringVar(&applyOptions.DryRyn, "dry-run", "", "pass dry-run to helm exec") return cmd } diff --git a/cmd/sync.go b/cmd/sync.go index a779da3a..7afd8ab6 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -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.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.DryRyn, "dry-run", "", "pass dry-run to helm exec") return cmd } diff --git a/pkg/app/app.go b/pkg/app/app.go index fbb35ce2..c0d314ce 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1536,6 +1536,7 @@ Do you really want to apply? PostRenderer: c.PostRenderer(), PostRendererArgs: c.PostRendererArgs(), SyncArgs: c.SyncArgs(), + DryRun: c.DryRun(), } return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), syncOpts) })) @@ -1929,6 +1930,7 @@ Do you really want to sync? PostRenderer: c.PostRenderer(), PostRendererArgs: c.PostRendererArgs(), SyncArgs: c.SyncArgs(), + DryRun: c.DryRun(), } return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), opts) })) diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index ab157567..394883ac 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -2196,6 +2196,7 @@ func (c configImpl) ShowOnly() []string { type applyConfig struct { args string cascade string + dryRun string values []string // TODO: Remove this function once Helmfile v0.x @@ -2415,6 +2416,10 @@ func (a applyConfig) ShowOnly() []string { return a.showOnly } +func (a applyConfig) DryRun() string { + return a.dryRun +} + type depsConfig struct { skipRepos bool includeTransitiveNeeds bool diff --git a/pkg/app/config.go b/pkg/app/config.go index 655485b7..7bf17e5e 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -52,6 +52,7 @@ type ApplyConfigProvider interface { PostRendererArgs() []string Cascade() string SuppressOutputLineRegex() []string + DryRun() string Values() []string Set() []string @@ -99,6 +100,7 @@ type SyncConfigProvider interface { PostRenderer() string PostRendererArgs() []string Cascade() string + DryRun() string Values() []string Set() []string diff --git a/pkg/config/apply.go b/pkg/config/apply.go index aab6ae7f..f884f87d 100644 --- a/pkg/config/apply.go +++ b/pkg/config/apply.go @@ -66,6 +66,8 @@ type ApplyOptions struct { SuppressOutputLineRegex []string // SyncArgs is the list of arguments to pass to helm upgrade. SyncArgs string + // DryRun is for helm dry-run flag + DryRyn string } // NewApply creates a new Apply @@ -247,3 +249,8 @@ func (a *ApplyImpl) SuppressOutputLineRegex() []string { func (a *ApplyImpl) SyncArgs() string { return a.ApplyOptions.SyncArgs } + +// DryRun returns dry-run flag +func (a *ApplyImpl) DryRun() string { + return a.ApplyOptions.DryRyn +} diff --git a/pkg/config/sync.go b/pkg/config/sync.go index 6950e39f..bcd7fd9a 100644 --- a/pkg/config/sync.go +++ b/pkg/config/sync.go @@ -34,6 +34,8 @@ type SyncOptions struct { Cascade string // SyncArgs is the list of arguments to pass to the helm upgrade command. SyncArgs string + // DryRun is for helm dry-run flag + DryRyn string } // NewSyncOptions creates a new Apply @@ -139,3 +141,8 @@ func (t *SyncImpl) Cascade() string { func (t *SyncImpl) SyncArgs() string { return t.SyncOptions.SyncArgs } + +// DryRun returns dry-run flag +func (t *SyncImpl) DryRun() string { + return t.SyncOptions.DryRyn +} diff --git a/pkg/state/helmx.go b/pkg/state/helmx.go index 404706ac..2ac9e26a 100644 --- a/pkg/state/helmx.go +++ b/pkg/state/helmx.go @@ -100,6 +100,12 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops * } 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 func (st *HelmState) appendCascadeFlags(flags []string, helm helmexec.Interface, release *ReleaseSpec, cascade string) []string { diff --git a/pkg/state/state.go b/pkg/state/state.go index b0b57362..6e6395c2 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -753,6 +753,7 @@ type SyncOpts struct { PostRenderer string PostRendererArgs []string SyncArgs string + DryRun string } type SyncOpt interface{ Apply(*SyncOpts) } @@ -2672,6 +2673,7 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp postRendererArgs = opt.PostRendererArgs } flags = st.appendPostRenderArgsFlags(flags, release, postRendererArgs) + flags = st.appendDryRunFlags(flags, opt) flags = st.appendExtraSyncFlags(flags, opt)