@@ -186,11 +186,6 @@ func (c *Client) createManaged(ctx context.Context, spec v1alpha1.ServiceInstanc
186186
187187// createUserProvided creates a user-provided service instance according to CR's ForProvider spec
188188func (c * Client ) createUserProvided (ctx context.Context , spec v1alpha1.ServiceInstanceParameters , creds json.RawMessage ) (* resource.ServiceInstance , error ) {
189- // Credential is required for UPS
190- if creds == nil {
191- return nil , errors .New ("Missing or invalid credentials" )
192- }
193-
194189 // throw error if no space is provided
195190 if spec .Space == nil {
196191 return nil , errors .New ("no space reference provided" )
@@ -203,9 +198,11 @@ func (c *Client) createUserProvided(ctx context.Context, spec v1alpha1.ServiceIn
203198 }
204199
205200 // workaround: cf-goclient supports few ups options at creation time.
206- upt := resource .NewServiceInstanceUserProvidedUpdate ().
207- WithCredentials (creds ).
208- WithRouteServiceURL (spec .RouteServiceURL ).
201+ upt := resource .NewServiceInstanceUserProvidedUpdate ()
202+ if creds != nil {
203+ upt .WithCredentials (creds )
204+ }
205+ upt .WithRouteServiceURL (spec .RouteServiceURL ).
209206 WithSyslogDrainURL (spec .SyslogDrainURL )
210207
211208 return c .ServiceInstance .UpdateUserProvided (ctx , si .GUID , upt )
@@ -265,15 +262,15 @@ func (c *Client) updateManaged(ctx context.Context, observed *resource.ServiceIn
265262func (c * Client ) updateUserProvided (ctx context.Context , observed * resource.ServiceInstance , desired * v1alpha1.ServiceInstanceParameters , creds json.RawMessage ) (* resource.ServiceInstance , error ) {
266263 upd := resource .NewServiceInstanceUserProvidedUpdate ()
267264
268- if creds == nil {
269- return nil , errors .New ("Missing or invalid credentials" )
270-
271- }
272265 if observed .Name != * desired .Name {
273266 upd .WithName (* desired .Name )
274267 }
275268
276- upd .WithRouteServiceURL (desired .RouteServiceURL ).WithSyslogDrainURL (desired .SyslogDrainURL ).WithCredentials (creds )
269+ if creds != nil {
270+ upd .WithCredentials (creds )
271+ }
272+ upd .WithRouteServiceURL (desired .RouteServiceURL ).
273+ WithSyslogDrainURL (desired .SyslogDrainURL )
277274
278275 return c .ServiceInstance .UpdateUserProvided (ctx , observed .GUID , upd )
279276}
0 commit comments