diff --git a/controllers/controllers/services/instances/managed/controller.go b/controllers/controllers/services/instances/managed/controller.go index 3cdb469d7..db5e91a8f 100644 --- a/controllers/controllers/services/instances/managed/controller.go +++ b/controllers/controllers/services/instances/managed/controller.go @@ -278,7 +278,7 @@ func (r *Reconciler) finalizeCFServiceInstance( return ctrl.Result{}, nil } - deprovisionResponse, err := r.deprovisionServiceInstance(ctx, serviceInstance) + deprovisionResponse, err := r.deprovisionServiceInstance(ctx, serviceInstance, assets, osbapiClient) if err != nil { log.Error(err, "failed to deprovision service instance with broker") return ctrl.Result{}, err @@ -302,23 +302,14 @@ func (r *Reconciler) finalizeCFServiceInstance( func (r *Reconciler) deprovisionServiceInstance( ctx context.Context, serviceInstance *korifiv1alpha1.CFServiceInstance, + assets osbapi.ServiceInstanceAssets, + osbapiClient osbapi.BrokerClient, ) (osbapi.ServiceInstanceOperationResponse, error) { - assets, err := r.assets.GetServiceInstanceAssets(ctx, serviceInstance) - if err != nil { - return osbapi.ServiceInstanceOperationResponse{}, fmt.Errorf("failed to get service instance assets: %w", err) - } - - osbapiClient, err := r.osbapiClientFactory.CreateClient(ctx, assets.ServiceBroker) - if err != nil { - return osbapi.ServiceInstanceOperationResponse{}, fmt.Errorf("failed to create broker client: %w", err) - } - serviceInstance.Status.LastOperation = services.LastOperation{ Type: "delete", State: "initial", } - var deprovisionResponse osbapi.ServiceInstanceOperationResponse - deprovisionResponse, err = osbapiClient.Deprovision(ctx, osbapi.InstanceDeprovisionPayload{ + deprovisionResponse, err := osbapiClient.Deprovision(ctx, osbapi.InstanceDeprovisionPayload{ ID: serviceInstance.Name, InstanceDeprovisionRequest: osbapi.InstanceDeprovisionRequest{ ServiceId: assets.ServiceOffering.Spec.BrokerCatalog.ID,