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