parent
							
								
									4b3ad24bc7
								
							
						
					
					
						commit
						b5095c04a4
					
				|  | @ -70,7 +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") | ||||
| 	f.StringVar(&applyOptions.DryRun, "dry-run", "", "pass dry-run to helm exec") | ||||
| 
 | ||||
| 	return cmd | ||||
| } | ||||
|  |  | |||
|  | @ -89,6 +89,11 @@ func (st *HelmState) appendWaitForJobsFlags(flags []string, release *ReleaseSpec | |||
| 	return flags | ||||
| } | ||||
| 
 | ||||
| // appendWaitFlags appends the appropriate wait flags to the given flags slice based on the provided release and sync options.
 | ||||
| // If release.Wait is true, "--wait" flag is added.
 | ||||
| // If ops.Wait is true, "--wait" flag is added.
 | ||||
| // If release.Wait is nil and st.HelmDefaults.Wait is true, "--wait" flag is added.
 | ||||
| // Returns the updated flags slice.
 | ||||
| func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *SyncOpts) []string { | ||||
| 	switch { | ||||
| 	case release.Wait != nil && *release.Wait: | ||||
|  | @ -100,6 +105,10 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops * | |||
| 	} | ||||
| 	return flags | ||||
| } | ||||
| 
 | ||||
| // 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, opt *SyncOpts) []string { | ||||
| 	if opt != nil && opt.DryRun != "" { | ||||
| 		flags = append(flags, "--dry-run", opt.DryRun) | ||||
|  |  | |||
|  | @ -279,9 +279,7 @@ func TestAppendShowOnlyFlags(t *testing.T) { | |||
| 
 | ||||
| func TestAppendDryRunFlags(t *testing.T) { | ||||
| 	type args struct { | ||||
| 		flags    []string | ||||
| 		dry-run  string | ||||
| 		helm     helmexec.Interface | ||||
| 		dryRun   string | ||||
| 		expected []string | ||||
| 	} | ||||
| 	tests := []struct { | ||||
|  | @ -291,18 +289,14 @@ func TestAppendDryRunFlags(t *testing.T) { | |||
| 		{ | ||||
| 			name: "do dry-run on client", | ||||
| 			args: args{ | ||||
| 				flags:    []string{}, | ||||
| 				dry-run:  "client", | ||||
| 				helm:     testutil.NewVersionHelmExec("3.12.1"), | ||||
| 				dryRun:   "client", | ||||
| 				expected: []string{"--dry-run", "client"}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: "do dry-run on server", | ||||
| 			args: args{ | ||||
| 				flags:    []string{}, | ||||
| 				dry-run:  "server", | ||||
| 				helm:     testutil.NewVersionHelmExec("3.12.1"), | ||||
| 				dryRun:   "server", | ||||
| 				expected: []string{"--dry-run", "server"}, | ||||
| 			}, | ||||
| 		}, | ||||
|  | @ -310,7 +304,9 @@ func TestAppendDryRunFlags(t *testing.T) { | |||
| 	for _, tt := range tests { | ||||
| 		t.Run(tt.name, func(t *testing.T) { | ||||
| 			st := &HelmState{} | ||||
| 			got := st.appendDryRunFlags(tt.args.flags, tt.args.helm, tt.args.release, tt.args.dry-run) | ||||
| 			got := st.appendDryRunFlags([]string{}, &SyncOpts{ | ||||
| 				DryRun: tt.args.dryRun, | ||||
| 			}) | ||||
| 			require.Equalf(t, tt.args.expected, got, "appendDryRunFlags() = %v, want %v", got, tt.args.expected) | ||||
| 		}) | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue