Skip to content

Commit

Permalink
Bug fixes (#59)
Browse files Browse the repository at this point in the history
* bug fix - nil pointer (get by id)
  • Loading branch information
kerenlahav authored Jan 3, 2021
1 parent 3611139 commit adcbd76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/serviceinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (r *ServiceInstanceReconciler) createInstance(ctx context.Context, serviceI
func (r *ServiceInstanceReconciler) updateInstance(ctx context.Context, serviceInstance *servicesv1alpha1.ServiceInstance, log logr.Logger, smClient smclient.Client) (ctrl.Result, error) {
var err error
var smServiceInstance *types.ServiceInstance
if smServiceInstance, err = smClient.GetInstanceByID(serviceInstance.Status.InstanceID, &smclient.Parameters{}); err != nil {
if smServiceInstance, err = smClient.GetInstanceByID(serviceInstance.Status.InstanceID, nil); err != nil {
if smErr, ok := err.(*smclient.ServiceManagerError); ok && smErr.StatusCode == http.StatusNotFound {
log.Info(fmt.Sprintf("instance ID %s not found in SM, recreating...", serviceInstance.Status.InstanceID))
serviceInstance.Status.InstanceID = ""
Expand Down
8 changes: 2 additions & 6 deletions internal/smclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ func (client *serviceManagerClient) ListInstances(q *Parameters) (*types.Service
// GetInstanceByID returns instance registered in the Service Manager satisfying provided queries
func (client *serviceManagerClient) GetInstanceByID(id string, q *Parameters) (*types.ServiceInstance, error) {
instance := &types.ServiceInstance{}
err := client.get(instance, web.ServiceInstancesURL+"/"+id, &Parameters{
GeneralParams: q.GeneralParams,
})
err := client.get(instance, web.ServiceInstancesURL+"/"+id, q)

return instance, err
}
Expand All @@ -229,9 +227,7 @@ func (client *serviceManagerClient) ListBindings(q *Parameters) (*types.ServiceB
// GetBindingByID returns binding registered in the Service Manager satisfying provided queries
func (client *serviceManagerClient) GetBindingByID(id string, q *Parameters) (*types.ServiceBinding, error) {
binding := &types.ServiceBinding{}
err := client.get(binding, web.ServiceBindingsURL+"/"+id, &Parameters{
GeneralParams: q.GeneralParams,
})
err := client.get(binding, web.ServiceBindingsURL+"/"+id, q)

return binding, err
}
Expand Down

0 comments on commit adcbd76

Please sign in to comment.