@@ -109,6 +109,8 @@ type ClusterProxy interface {
109
109
// createOrUpdateConfig contains options for use with CreateOrUpdate.
110
110
type createOrUpdateConfig struct {
111
111
labelSelector labels.Selector
112
+ createOpts []client.CreateOption
113
+ updateOpts []client.UpdateOption
112
114
}
113
115
114
116
// CreateOrUpdateOption is a configuration option supplied to CreateOrUpdate.
@@ -121,6 +123,20 @@ func WithLabelSelector(labelSelector labels.Selector) CreateOrUpdateOption {
121
123
}
122
124
}
123
125
126
+ // WithCreateOpts allows definition of the Create options to be used in resource Create.
127
+ func WithCreateOpts (createOpts ... client.CreateOption ) CreateOrUpdateOption {
128
+ return func (c * createOrUpdateConfig ) {
129
+ c .createOpts = createOpts
130
+ }
131
+ }
132
+
133
+ // WithUpdateOpts allows definition of the Update options to be used in resource Update.
134
+ func WithUpdateOpts (updateOpts ... client.UpdateOption ) CreateOrUpdateOption {
135
+ return func (c * createOrUpdateConfig ) {
136
+ c .updateOpts = updateOpts
137
+ }
138
+ }
139
+
124
140
// ClusterLogCollector defines an object that can collect logs from a machine.
125
141
type ClusterLogCollector interface {
126
142
// CollectMachineLog collects log from a machine.
@@ -320,15 +336,15 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt
320
336
if err := p .GetClient ().Get (ctx , objectKey , existingObject ); err != nil {
321
337
// Expected error -- if the object does not exist, create it
322
338
if apierrors .IsNotFound (err ) {
323
- if err := p .GetClient ().Create (ctx , & o ); err != nil {
339
+ if err := p .GetClient ().Create (ctx , & o , config . createOpts ... ); err != nil {
324
340
retErrs = append (retErrs , err )
325
341
}
326
342
} else {
327
343
retErrs = append (retErrs , err )
328
344
}
329
345
} else {
330
346
o .SetResourceVersion (existingObject .GetResourceVersion ())
331
- if err := p .GetClient ().Update (ctx , & o ); err != nil {
347
+ if err := p .GetClient ().Update (ctx , & o , config . updateOpts ... ); err != nil {
332
348
retErrs = append (retErrs , err )
333
349
}
334
350
}
0 commit comments