mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 03:27:16 +02:00
+3
-3
@@ -109,12 +109,12 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *
|
||||
// appendDryRunFlags appends the necessary flags for a dry run to the given flags slice.
|
||||
// If the opt parameter is not nil and opt.DryRun is not empty, the "--dry-run" flag and the value of opt.DryRun are appended to the flags slice.
|
||||
// The updated flags slice is returned.
|
||||
func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface, opt *SyncOpts) []string {
|
||||
func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface, dryRun string) []string {
|
||||
if !helm.IsVersionAtLeast("3.13.0") {
|
||||
return flags
|
||||
}
|
||||
if opt != nil && opt.DryRun != "" {
|
||||
flags = append(flags, fmt.Sprintf("--dry-run=%s", opt.DryRun))
|
||||
if dryRun != "" {
|
||||
flags = append(flags, fmt.Sprintf("--dry-run=%s", dryRun))
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
@@ -328,9 +328,7 @@ func TestAppendDryRunFlags(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
st := &HelmState{}
|
||||
got := st.appendDryRunFlags([]string{}, tt.args.helm, &SyncOpts{
|
||||
DryRun: tt.args.dryRun,
|
||||
})
|
||||
got := st.appendDryRunFlags([]string{}, tt.args.helm, tt.args.dryRun)
|
||||
require.Equalf(t, tt.args.expected, got, "appendDryRunFlags() = %v, want %v", got, tt.args.expected)
|
||||
})
|
||||
}
|
||||
|
||||
+7
-1
@@ -1967,6 +1967,7 @@ type DiffOpts struct {
|
||||
PostRenderer string
|
||||
PostRendererArgs []string
|
||||
SuppressOutputLineRegex []string
|
||||
DryRun string
|
||||
}
|
||||
|
||||
func (o *DiffOpts) Apply(opts *DiffOpts) {
|
||||
@@ -2673,7 +2674,9 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
||||
postRendererArgs = opt.PostRendererArgs
|
||||
}
|
||||
flags = st.appendPostRenderArgsFlags(flags, release, postRendererArgs)
|
||||
flags = st.appendDryRunFlags(flags, helm, opt)
|
||||
if opt != nil && opt.DryRun != "" {
|
||||
flags = st.appendDryRunFlags(flags, helm, opt.DryRun)
|
||||
}
|
||||
|
||||
flags = st.appendExtraSyncFlags(flags, opt)
|
||||
|
||||
@@ -2795,6 +2798,9 @@ func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec,
|
||||
if err != nil {
|
||||
return nil, files, err
|
||||
}
|
||||
if opt != nil && opt.DryRun != "" {
|
||||
flags = st.appendDryRunFlags(flags, helm, opt.DryRun)
|
||||
}
|
||||
|
||||
return append(flags, common...), files, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user