@@ -109,6 +109,8 @@ type ClusterProxy interface {
109109// createOrUpdateConfig contains options for use with CreateOrUpdate.
110110type createOrUpdateConfig struct {
111111 labelSelector labels.Selector
112+ createOpts []client.CreateOption
113+ updateOpts []client.UpdateOption
112114}
113115
114116// CreateOrUpdateOption is a configuration option supplied to CreateOrUpdate.
@@ -121,6 +123,20 @@ func WithLabelSelector(labelSelector labels.Selector) CreateOrUpdateOption {
121123 }
122124}
123125
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+
124140// ClusterLogCollector defines an object that can collect logs from a machine.
125141type ClusterLogCollector interface {
126142 // CollectMachineLog collects log from a machine.
@@ -320,15 +336,15 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt
320336 if err := p .GetClient ().Get (ctx , objectKey , existingObject ); err != nil {
321337 // Expected error -- if the object does not exist, create it
322338 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 {
324340 retErrs = append (retErrs , err )
325341 }
326342 } else {
327343 retErrs = append (retErrs , err )
328344 }
329345 } else {
330346 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 {
332348 retErrs = append (retErrs , err )
333349 }
334350 }
0 commit comments