diff --git a/api/payloads/service_binding.go b/api/payloads/service_binding.go index 767e9de2b..8899e3629 100644 --- a/api/payloads/service_binding.go +++ b/api/payloads/service_binding.go @@ -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, } } diff --git a/api/payloads/service_binding_test.go b/api/payloads/service_binding_test.go index 701f634ea..066e325de 100644 --- a/api/payloads/service_binding_test.go +++ b/api/payloads/service_binding_test.go @@ -25,7 +25,7 @@ var _ = Describe("ServiceBindingList", func() { Entry("app_guids", "app_guids=app_guid", payloads.ServiceBindingList{AppGUIDs: "app_guid"}), Entry("service_instance_guids", "service_instance_guids=si_guid", payloads.ServiceBindingList{ServiceInstanceGUIDs: "si_guid"}), Entry("include", "include=app", payloads.ServiceBindingList{Include: "app"}), - Entry("include", "include=key", payloads.ServiceBindingList{Include: "key"}), + Entry("include", "include=service_instance", payloads.ServiceBindingList{Include: "service_instance"}), Entry("label_selector=foo", "label_selector=foo", payloads.ServiceBindingList{LabelSelector: "foo"}), Entry("service_plan_guids=plan-guid", "service_plan_guids=plan-guid", payloads.ServiceBindingList{PlanGUIDs: "plan-guid"}), ) diff --git a/api/repositories/service_binding_repository_test.go b/api/repositories/service_binding_repository_test.go index fbad8ccc7..f5ab0e653 100644 --- a/api/repositories/service_binding_repository_test.go +++ b/api/repositories/service_binding_repository_test.go @@ -800,6 +800,7 @@ var _ = Describe("ServiceBindingRepo", func() { Namespace: space2.Name, Labels: map[string]string{ korifiv1alpha1.PlanGUIDLabelKey: "plan-4", + korifiv1alpha1.SpaceGUIDKey: space.Name, }, }, Spec: korifiv1alpha1.CFServiceBindingSpec{ diff --git a/controllers/api/v1alpha1/cfservicebinding_types.go b/controllers/api/v1alpha1/cfservicebinding_types.go index b092e8460..abb36c838 100644 --- a/controllers/api/v1alpha1/cfservicebinding_types.go +++ b/controllers/api/v1alpha1/cfservicebinding_types.go @@ -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 diff --git a/controllers/controllers/services/bindings/controller_test.go b/controllers/controllers/services/bindings/controller_test.go index c25b2302d..d0252075f 100644 --- a/controllers/controllers/services/bindings/controller_test.go +++ b/controllers/controllers/services/bindings/controller_test.go @@ -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{ diff --git a/controllers/controllers/services/bindings/managed/controller.go b/controllers/controllers/services/bindings/managed/controller.go index 1300dec35..6a3407c64 100644 --- a/controllers/controllers/services/bindings/managed/controller.go +++ b/controllers/controllers/services/bindings/managed/controller.go @@ -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) diff --git a/controllers/controllers/services/bindings/sbio/servicebinding.go b/controllers/controllers/services/bindings/sbio/servicebinding.go index cdff4a669..dc373abdb 100644 --- a/controllers/controllers/services/bindings/sbio/servicebinding.go +++ b/controllers/controllers/services/bindings/sbio/servicebinding.go @@ -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{ diff --git a/controllers/controllers/services/bindings/sbio/servicebinding_test.go b/controllers/controllers/services/bindings/sbio/servicebinding_test.go index edaf15d8c..58325b0ed 100644 --- a/controllers/controllers/services/bindings/sbio/servicebinding_test.go +++ b/controllers/controllers/services/bindings/sbio/servicebinding_test.go @@ -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{