Skip to content

Commit

Permalink
Added key type filter in managed controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ddraganovv committed Jan 9, 2025
1 parent ae722ab commit b40cd98
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions api/payloads/service_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (l *ServiceBindingList) ToMessage() repositories.ListServiceBindingsMessage
AppGUIDs: parse.ArrayParam(l.AppGUIDs),
LabelSelector: l.LabelSelector,
PlanGUIDs: parse.ArrayParam(l.PlanGUIDs),
Type: &l.Type,
}
}

Expand Down
5 changes: 2 additions & 3 deletions controllers/api/v1alpha1/cfservicebinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ const (
ServiceInstanceTypeAnnotationKey = "korifi.cloudfoundry.org/service-instance-type"
PlanGUIDLabelKey = "korifi.cloudfoundry.org/plan-guid"

ServiceBindingGUIDLabel = "korifi.cloudfoundry.org/service-binding-guid"
ServiceCredentialBindingTypeLabel = "korifi.cloudfoundry.org/service-credential-binding-type"
CFServiceBindingFinalizerName = "cfServiceBinding.korifi.cloudfoundry.org"
ServiceBindingGUIDLabel = "korifi.cloudfoundry.org/service-binding-guid"
CFServiceBindingFinalizerName = "cfServiceBinding.korifi.cloudfoundry.org"
)

// CFServiceBindingSpec defines the desired state of CFServiceBinding
Expand Down
17 changes: 17 additions & 0 deletions controllers/controllers/services/bindings/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,23 @@ var _ = Describe("CFServiceBinding", func() {
}).Should(Succeed())
})

When("binding is of type key", func() {
BeforeEach(func() {
Expect(k8s.Patch(ctx, adminClient, binding, func() {
binding.Spec.Type = korifiv1alpha1.CFServiceBindingTypeKey
})).To(Succeed())
})

It("does not create servicebinding.io", func() {
Consistently(func(g Gomega) {
sbList := &servicebindingv1beta1.ServiceBindingList{}
err := adminClient.List(ctx, sbList, client.InNamespace(testNamespace))
g.Expect(err).To(BeNil())
g.Expect(sbList.Items).To(BeEmpty())
}).Should(Succeed())
})
})

When("the credentials contain type key", func() {
BeforeEach(func() {
brokerClient.BindReturns(osbapi.BindResponse{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (r *ManagedBindingsReconciler) ReconcileResource(ctx context.Context, cfSer
return ctrl.Result{}, err
}

if cfServiceBinding.Spec.Type == korifiv1alpha1.CFServiceBindingTypeKey {
return ctrl.Result{}, nil
}

sbServiceBinding, err := r.reconcileSBServiceBinding(ctx, cfServiceBinding)
if err != nil {
log.Info("error creating/updating servicebinding.io servicebinding", "reason", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ func ToSBServiceBinding(cfServiceBinding *korifiv1alpha1.CFServiceBinding, bindi
Name: fmt.Sprintf("cf-binding-%s", cfServiceBinding.Name),
Namespace: cfServiceBinding.Namespace,
Labels: map[string]string{
korifiv1alpha1.ServiceBindingGUIDLabel: cfServiceBinding.Name,
korifiv1alpha1.CFAppGUIDLabelKey: cfServiceBinding.Spec.AppRef.Name,
korifiv1alpha1.ServiceCredentialBindingTypeLabel: "app",
korifiv1alpha1.ServiceBindingGUIDLabel: cfServiceBinding.Name,
korifiv1alpha1.CFAppGUIDLabelKey: cfServiceBinding.Spec.AppRef.Name,
korifiv1alpha1.ServiceBindingTypeLabel: "app",
},
},
Spec: servicebindingv1beta1.ServiceBindingSpec{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ var _ = Describe("SBIO", func() {
Name: "cf-binding-cf-binding",
Namespace: cfServiceBinding.Namespace,
Labels: map[string]string{
korifiv1alpha1.ServiceBindingGUIDLabel: bindingName,
korifiv1alpha1.CFAppGUIDLabelKey: cfServiceBinding.Spec.AppRef.Name,
korifiv1alpha1.ServiceCredentialBindingTypeLabel: "app",
korifiv1alpha1.ServiceBindingGUIDLabel: bindingName,
korifiv1alpha1.CFAppGUIDLabelKey: cfServiceBinding.Spec.AppRef.Name,
korifiv1alpha1.ServiceBindingTypeLabel: "app",
},
},
Spec: servicebindingv1beta1.ServiceBindingSpec{
Expand Down

0 comments on commit b40cd98

Please sign in to comment.