fix more issue

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2024-06-02 15:03:54 +08:00
parent cc3202e9b9
commit 61b4199c80
12 changed files with 64 additions and 25 deletions
+3 -3
View File
@@ -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
}
+1 -3
View File
@@ -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
View File
@@ -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
}