diff --git a/api/v1alpha1/dbaasprovider.go b/api/v1alpha1/dbaasprovider.go index f3b8d4fc..e0f005b3 100644 --- a/api/v1alpha1/dbaasprovider.go +++ b/api/v1alpha1/dbaasprovider.go @@ -214,11 +214,10 @@ type DBaaSConnectionSpec struct { type DBaaSConnectionStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` - // Secret holding the credentials needed for accessing the DB instance - CredentialsRef *corev1.LocalObjectReference `json:"credentialsRef,omitempty"` - - // A ConfigMap holding non-sensitive information needed for connecting to the DB instance - ConnectionInfoRef *corev1.LocalObjectReference `json:"connectionInfoRef,omitempty"` + // Binding exposes a secret containing the binding information for the + // instance. It implements the service binding Provisioned Service + // duck type. See: https://github.com/servicebinding/spec#provisioned-service + Binding *corev1.LocalObjectReference `json:"binding,omitempty"` } // DBaaSProviderConnection is the schema for unmarshalling provider connection object diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index c0d42ec0..cdf2d019 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -132,13 +132,8 @@ func (in *DBaaSConnectionStatus) DeepCopyInto(out *DBaaSConnectionStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.CredentialsRef != nil { - in, out := &in.CredentialsRef, &out.CredentialsRef - *out = new(v1.LocalObjectReference) - **out = **in - } - if in.ConnectionInfoRef != nil { - in, out := &in.ConnectionInfoRef, &out.ConnectionInfoRef + if in.Binding != nil { + in, out := &in.Binding, &out.Binding *out = new(v1.LocalObjectReference) **out = **in } diff --git a/bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml b/bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml index 30d3125e..63153b52 100644 --- a/bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml +++ b/bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml @@ -3,9 +3,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.1 - service.binding/configuration: path={.status.connectionInfoRef.name},objectType=ConfigMap - service.binding/credentials: path={.status.credentialsRef.name},objectType=Secret creationTimestamp: null + labels: + servicebinding.io/provisioned-service: "true" name: dbaasconnections.dbaas.redhat.com spec: group: dbaas.redhat.com @@ -71,6 +71,16 @@ spec: status: description: DBaaSConnectionStatus defines the observed state of DBaaSConnection properties: + binding: + description: 'Binding exposes a secret containing the binding information + for the instance. It implements the service binding Provisioned + Service duck type. See: https://github.com/servicebinding/spec#provisioned-service' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object conditions: items: description: "Condition contains details for one aspect of the current @@ -140,24 +150,6 @@ spec: - type type: object type: array - connectionInfoRef: - description: A ConfigMap holding non-sensitive information needed - for connecting to the DB instance - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - credentialsRef: - description: Secret holding the credentials needed for accessing the - DB instance - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object type: object type: object served: true diff --git a/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml b/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml index fcb3cebf..ef3ab8d8 100644 --- a/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml +++ b/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml @@ -71,6 +71,16 @@ spec: status: description: DBaaSConnectionStatus defines the observed state of DBaaSConnection properties: + binding: + description: 'Binding exposes a secret containing the binding information + for the instance. It implements the service binding Provisioned + Service duck type. See: https://github.com/servicebinding/spec#provisioned-service' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object conditions: items: description: "Condition contains details for one aspect of the current @@ -140,24 +150,6 @@ spec: - type type: object type: array - connectionInfoRef: - description: A ConfigMap holding non-sensitive information needed - for connecting to the DB instance - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - credentialsRef: - description: Secret holding the credentials needed for accessing the - DB instance - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object type: object type: object served: true diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 5031e288..ac6abceb 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -11,7 +11,7 @@ resources: #+kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: -- patches/service_binding_annotations.yaml +- patches/service_binding_labels.yaml # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD diff --git a/config/crd/patches/service_binding_annotations.yaml b/config/crd/patches/service_binding_annotations.yaml deleted file mode 100644 index a5e1e8fc..00000000 --- a/config/crd/patches/service_binding_annotations.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: dbaasconnections.dbaas.redhat.com - annotations: - service.binding/credentials: 'path={.status.credentialsRef.name},objectType=Secret' - service.binding/configuration: 'path={.status.connectionInfoRef.name},objectType=ConfigMap' diff --git a/config/crd/patches/service_binding_labels.yaml b/config/crd/patches/service_binding_labels.yaml new file mode 100644 index 00000000..adfea8b6 --- /dev/null +++ b/config/crd/patches/service_binding_labels.yaml @@ -0,0 +1,6 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: dbaasconnections.dbaas.redhat.com + labels: + servicebinding.io/provisioned-service: "true" diff --git a/controllers/dbaasconnection_controller_test.go b/controllers/dbaasconnection_controller_test.go index 71950490..617940fd 100644 --- a/controllers/dbaasconnection_controller_test.go +++ b/controllers/dbaasconnection_controller_test.go @@ -406,12 +406,9 @@ var _ = Describe("DBaaSConnection controller - nominal", func() { LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) @@ -601,12 +598,9 @@ var _ = Describe("DBaaSConnection controller - nominal with instance reference", LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) @@ -702,12 +696,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() { LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) @@ -809,12 +800,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() { LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) @@ -934,12 +922,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() { LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) @@ -1045,12 +1030,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() { LastTransitionTime: metav1.Time{Time: lastTransitionTime}, }, }, - CredentialsRef: &v1.LocalObjectReference{ + Binding: &v1.LocalObjectReference{ Name: testSecret.Name, }, - ConnectionInfoRef: &v1.LocalObjectReference{ - Name: "testConnectionInfoRef", - }, } It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status)) }) diff --git a/test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml b/test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml index 7cd3184b..bc766712 100644 --- a/test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml +++ b/test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml @@ -70,6 +70,16 @@ spec: status: description: DBaaSConnectionStatus defines the observed state of DBaaSConnection properties: + binding: + description: 'Binding exposes a secret containing the binding information + for the instance. It implements the service binding Provisioned + Service duck type. See: https://github.com/servicebinding/spec#provisioned-service' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object conditions: items: description: "Condition contains details for one aspect of the current @@ -139,16 +149,6 @@ spec: - type type: object type: array - connectionInfoRef: - properties: - name: - type: string - type: object - credentialsRef: - properties: - name: - type: string - type: object type: object type: object served: true diff --git a/test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml b/test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml index f9e91cf4..df79ef84 100644 --- a/test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml +++ b/test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml @@ -74,6 +74,16 @@ spec: status: description: DBaaSConnectionStatus defines the observed state of DBaaSConnection properties: + binding: + description: 'Binding exposes a secret containing the binding information + for the instance. It implements the service binding Provisioned + Service duck type. See: https://github.com/servicebinding/spec#provisioned-service' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object conditions: items: description: "Condition contains details for one aspect of the current @@ -143,16 +153,6 @@ spec: - type type: object type: array - connectionInfoRef: - properties: - name: - type: string - type: object - credentialsRef: - properties: - name: - type: string - type: object type: object type: object served: true