@@ -23,7 +23,6 @@ import (
23
23
24
24
var (
25
25
noPrune = false
26
- serverDryRun = false
27
26
previewDestroy = false
28
27
)
29
28
@@ -44,7 +43,12 @@ func GetPreviewRunner(provider provider.Provider, ioStreams genericclioptions.IO
44
43
}
45
44
46
45
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." )
48
52
cmd .Flags ().BoolVar (& previewDestroy , "destroy" , previewDestroy , "If true, preview of destroy operations will be displayed." )
49
53
cmd .Flags ().StringVar (& r .output , "output" , printers .DefaultPrinter (),
50
54
fmt .Sprintf ("Output format, must be one of %s" , strings .Join (printers .SupportedPrinters (), "," )))
@@ -67,7 +71,8 @@ type PreviewRunner struct {
67
71
Destroyer * apply.Destroyer
68
72
provider provider.Provider
69
73
70
- output string
74
+ serverSideOptions common.ServerSideOptions
75
+ output string
71
76
}
72
77
73
78
// RunE is the function run from the cobra command.
@@ -83,7 +88,7 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
83
88
}
84
89
85
90
drs := common .DryRunClient
86
- if serverDryRun {
91
+ if r . serverSideOptions . ServerSideApply {
87
92
drs = common .DryRunServer
88
93
}
89
94
@@ -118,16 +123,11 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
118
123
119
124
// Run the applier. It will return a channel where we can receive updates
120
125
// to keep track of progress and any issues.
121
- serverSideOptions := common.ServerSideOptions {
122
- ServerSideApply : false ,
123
- ForceConflicts : false ,
124
- FieldManager : common .DefaultFieldManager ,
125
- }
126
126
ch = r .Applier .Run (ctx , objs , apply.Options {
127
127
EmitStatusEvents : false ,
128
128
NoPrune : noPrune ,
129
129
DryRunStrategy : drs ,
130
- ServerSideOptions : serverSideOptions ,
130
+ ServerSideOptions : r . serverSideOptions ,
131
131
})
132
132
} else {
133
133
inv , _ , err := inventory .SplitUnstructureds (objs )
0 commit comments