@@ -152,7 +152,7 @@ func (c *Client) Create(ctx context.Context, spec v1alpha1.ServiceInstanceParame
152152 return c .createManaged (ctx , spec , creds )
153153
154154 case v1alpha1 .UserProvidedService :
155- return c .createUserProvided (ctx , spec )
155+ return c .createUserProvided (ctx , spec , creds )
156156 default :
157157 return nil , errors .New ("unknown service instance type" )
158158 }
@@ -185,7 +185,7 @@ func (c *Client) createManaged(ctx context.Context, spec v1alpha1.ServiceInstanc
185185}
186186
187187// createUserProvided creates a user-provided service instance according to CR's ForProvider spec
188- func (c * Client ) createUserProvided (ctx context.Context , spec v1alpha1.ServiceInstanceParameters ) (* resource.ServiceInstance , error ) {
188+ func (c * Client ) createUserProvided (ctx context.Context , spec v1alpha1.ServiceInstanceParameters , creds json. RawMessage ) (* resource.ServiceInstance , error ) {
189189 // throw error if no space is provided
190190 if spec .Space == nil {
191191 return nil , errors .New ("no space reference provided" )
@@ -198,8 +198,11 @@ func (c *Client) createUserProvided(ctx context.Context, spec v1alpha1.ServiceIn
198198 }
199199
200200 // workaround: cf-goclient supports few ups options at creation time.
201- upt := resource .NewServiceInstanceUserProvidedUpdate ().
202- WithRouteServiceURL (spec .RouteServiceURL ).
201+ upt := resource .NewServiceInstanceUserProvidedUpdate ()
202+ if creds != nil {
203+ upt .WithCredentials (creds )
204+ }
205+ upt .WithRouteServiceURL (spec .RouteServiceURL ).
203206 WithSyslogDrainURL (spec .SyslogDrainURL )
204207
205208 return c .ServiceInstance .UpdateUserProvided (ctx , si .GUID , upt )
@@ -259,15 +262,15 @@ func (c *Client) updateManaged(ctx context.Context, observed *resource.ServiceIn
259262func (c * Client ) updateUserProvided (ctx context.Context , observed * resource.ServiceInstance , desired * v1alpha1.ServiceInstanceParameters , creds json.RawMessage ) (* resource.ServiceInstance , error ) {
260263 upd := resource .NewServiceInstanceUserProvidedUpdate ()
261264
262- if creds == nil {
263- return nil , errors .New ("Missing or invalid credentials" )
264-
265- }
266265 if observed .Name != * desired .Name {
267266 upd .WithName (* desired .Name )
268267 }
269268
270- 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 )
271274
272275 return c .ServiceInstance .UpdateUserProvided (ctx , observed .GUID , upd )
273276}
0 commit comments