Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
klapkov committed Nov 26, 2024
1 parent b0f67f4 commit 35a1f9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/repositories/service_instance_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func (r *ServiceInstanceRepo) DeleteServiceInstance(ctx context.Context, authInf
return ServiceInstanceRecord{}, fmt.Errorf("failed to remove finalizer for service instance: %s, %w", message.GUID, apierrors.FromK8sError(err, ServiceInstanceResourceType))
}

if err = r.DeleteServiceBindings(ctx, userClient, namespace, message.GUID); err != nil {
if err = r.removeBindingsFinalizer(ctx, userClient, namespace, message.GUID); err != nil {
return ServiceInstanceRecord{}, fmt.Errorf("failed delete related service bindings for instance: %s, %w", message.GUID, apierrors.FromK8sError(err, ServiceBindingResourceType))
}
}
Expand Down Expand Up @@ -522,7 +522,7 @@ func (r *ServiceInstanceRepo) GetDeletedAt(ctx context.Context, authInfo authori
return serviceInstance.DeletedAt, nil
}

func (r *ServiceInstanceRepo) DeleteServiceBindings(ctx context.Context, userClient client.WithWatch, namespace, instanceGUID string) error {
func (r *ServiceInstanceRepo) removeBindingsFinalizer(ctx context.Context, userClient client.WithWatch, namespace, instanceGUID string) error {
serviceBindings := new(korifiv1alpha1.CFServiceBindingList)
if err := userClient.List(ctx, serviceBindings, client.InNamespace(namespace)); err != nil {
return fmt.Errorf("failed to get service bindings: %w", apierrors.FromK8sError(err, ServiceBindingResourceType))
Expand Down
5 changes: 3 additions & 2 deletions api/repositories/service_instance_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,9 @@ var _ = Describe("ServiceInstanceRepository", func() {
ObjectMeta: metav1.ObjectMeta{
Name: uuid.NewString(),
Namespace: space.Name,
Finalizers: []string{
korifiv1alpha1.CFServiceBindingFinalizerName,
},
},
Spec: korifiv1alpha1.CFServiceBindingSpec{
Service: corev1.ObjectReference{
Expand All @@ -1055,8 +1058,6 @@ var _ = Describe("ServiceInstanceRepository", func() {
},
},
}

serviceBinding.Finalizers = append(serviceBinding.Finalizers, korifiv1alpha1.CFServiceBindingFinalizerName)
Expect(k8sClient.Create(ctx, serviceBinding)).To(Succeed())

deleteMessage = repositories.DeleteServiceInstanceMessage{
Expand Down

0 comments on commit 35a1f9b

Please sign in to comment.