Skip to content

Commit 0c52068

Browse files
committed
Adds more server-side flags to preview command
1 parent 8400b85 commit 0c52068

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cmd/preview/cmdpreview.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
var (
2525
noPrune = false
26-
serverDryRun = false
2726
previewDestroy = false
2827
)
2928

@@ -44,7 +43,12 @@ func GetPreviewRunner(provider provider.Provider, ioStreams genericclioptions.IO
4443
}
4544

4645
cmd.Flags().BoolVar(&noPrune, "no-prune", noPrune, "If true, do not prune previously applied objects.")
47-
cmd.Flags().BoolVar(&serverDryRun, "server-side", serverDryRun, "If true, preview runs in the server instead of the client.")
46+
cmd.Flags().BoolVar(&r.serverSideOptions.ServerSideApply, "server-side", false,
47+
"If true, preview runs in the server instead of the client.")
48+
cmd.Flags().BoolVar(&r.serverSideOptions.ForceConflicts, "force-conflicts", false,
49+
"If true during server-side preview, do not report field conflicts.")
50+
cmd.Flags().StringVar(&r.serverSideOptions.FieldManager, "field-manager", common.DefaultFieldManager,
51+
"If true during server-side preview, sets field owner.")
4852
cmd.Flags().BoolVar(&previewDestroy, "destroy", previewDestroy, "If true, preview of destroy operations will be displayed.")
4953
cmd.Flags().StringVar(&r.output, "output", printers.DefaultPrinter(),
5054
fmt.Sprintf("Output format, must be one of %s", strings.Join(printers.SupportedPrinters(), ",")))
@@ -67,7 +71,8 @@ type PreviewRunner struct {
6771
Destroyer *apply.Destroyer
6872
provider provider.Provider
6973

70-
output string
74+
serverSideOptions common.ServerSideOptions
75+
output string
7176
}
7277

7378
// RunE is the function run from the cobra command.
@@ -83,7 +88,7 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
8388
}
8489

8590
drs := common.DryRunClient
86-
if serverDryRun {
91+
if r.serverSideOptions.ServerSideApply {
8792
drs = common.DryRunServer
8893
}
8994

@@ -118,16 +123,11 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
118123

119124
// Run the applier. It will return a channel where we can receive updates
120125
// to keep track of progress and any issues.
121-
serverSideOptions := common.ServerSideOptions{
122-
ServerSideApply: false,
123-
ForceConflicts: false,
124-
FieldManager: common.DefaultFieldManager,
125-
}
126126
ch = r.Applier.Run(ctx, objs, apply.Options{
127127
EmitStatusEvents: false,
128128
NoPrune: noPrune,
129129
DryRunStrategy: drs,
130-
ServerSideOptions: serverSideOptions,
130+
ServerSideOptions: r.serverSideOptions,
131131
})
132132
} else {
133133
inv, _, err := inventory.SplitUnstructureds(objs)

0 commit comments

Comments
 (0)