Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Co-authored-by: Danail Branekov <danailster@gmail.com>
  • Loading branch information
uzabanov and danail-branekov committed Dec 19, 2024
1 parent 151f9ab commit 1848a55
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions controllers/controllers/services/instances/managed/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 1848a55

Please sign in to comment.