Skip to content

Commit 018ac59

Browse files
committed
DBAAS-831: update DBaaSConnection status to conform to the Provisioned Service ducktype defined in the Service Binding Specification for Kubernetes
1 parent d4fa962 commit 018ac59

10 files changed

+61
-102
lines changed

api/v1alpha1/dbaasprovider.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,10 @@ type DBaaSConnectionSpec struct {
214214
type DBaaSConnectionStatus struct {
215215
Conditions []metav1.Condition `json:"conditions,omitempty"`
216216

217-
// Secret holding the credentials needed for accessing the DB instance
218-
CredentialsRef *corev1.LocalObjectReference `json:"credentialsRef,omitempty"`
219-
220-
// A ConfigMap holding non-sensitive information needed for connecting to the DB instance
221-
ConnectionInfoRef *corev1.LocalObjectReference `json:"connectionInfoRef,omitempty"`
217+
// Binding exposes a secret containing the binding information for the
218+
// instance. It implements the service binding Provisioned Service
219+
// duck type. See: https://github.com/servicebinding/spec#provisioned-service
220+
Binding *corev1.LocalObjectReference `json:"binding,omitempty"`
222221
}
223222

224223
// DBaaSProviderConnection is the schema for unmarshalling provider connection object

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ kind: CustomResourceDefinition
33
metadata:
44
annotations:
55
controller-gen.kubebuilder.io/version: v0.4.1
6-
service.binding/configuration: path={.status.connectionInfoRef.name},objectType=ConfigMap
7-
service.binding/credentials: path={.status.credentialsRef.name},objectType=Secret
86
creationTimestamp: null
7+
labels:
8+
servicebinding.io/provisioned-service: "true"
99
name: dbaasconnections.dbaas.redhat.com
1010
spec:
1111
group: dbaas.redhat.com
@@ -71,6 +71,16 @@ spec:
7171
status:
7272
description: DBaaSConnectionStatus defines the observed state of DBaaSConnection
7373
properties:
74+
binding:
75+
description: 'Binding exposes a secret containing the binding information
76+
for the instance. It implements the service binding Provisioned
77+
Service duck type. See: https://github.com/servicebinding/spec#provisioned-service'
78+
properties:
79+
name:
80+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
81+
TODO: Add other useful fields. apiVersion, kind, uid?'
82+
type: string
83+
type: object
7484
conditions:
7585
items:
7686
description: "Condition contains details for one aspect of the current
@@ -140,24 +150,6 @@ spec:
140150
- type
141151
type: object
142152
type: array
143-
connectionInfoRef:
144-
description: A ConfigMap holding non-sensitive information needed
145-
for connecting to the DB instance
146-
properties:
147-
name:
148-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
149-
TODO: Add other useful fields. apiVersion, kind, uid?'
150-
type: string
151-
type: object
152-
credentialsRef:
153-
description: Secret holding the credentials needed for accessing the
154-
DB instance
155-
properties:
156-
name:
157-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
158-
TODO: Add other useful fields. apiVersion, kind, uid?'
159-
type: string
160-
type: object
161153
type: object
162154
type: object
163155
served: true

config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ spec:
7171
status:
7272
description: DBaaSConnectionStatus defines the observed state of DBaaSConnection
7373
properties:
74+
binding:
75+
description: 'Binding exposes a secret containing the binding information
76+
for the instance. It implements the service binding Provisioned
77+
Service duck type. See: https://github.com/servicebinding/spec#provisioned-service'
78+
properties:
79+
name:
80+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
81+
TODO: Add other useful fields. apiVersion, kind, uid?'
82+
type: string
83+
type: object
7484
conditions:
7585
items:
7686
description: "Condition contains details for one aspect of the current
@@ -140,24 +150,6 @@ spec:
140150
- type
141151
type: object
142152
type: array
143-
connectionInfoRef:
144-
description: A ConfigMap holding non-sensitive information needed
145-
for connecting to the DB instance
146-
properties:
147-
name:
148-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
149-
TODO: Add other useful fields. apiVersion, kind, uid?'
150-
type: string
151-
type: object
152-
credentialsRef:
153-
description: Secret holding the credentials needed for accessing the
154-
DB instance
155-
properties:
156-
name:
157-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
158-
TODO: Add other useful fields. apiVersion, kind, uid?'
159-
type: string
160-
type: object
161153
type: object
162154
type: object
163155
served: true

config/crd/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resources:
1111
#+kubebuilder:scaffold:crdkustomizeresource
1212

1313
patchesStrategicMerge:
14-
- patches/service_binding_annotations.yaml
14+
- patches/service_binding_labels.yaml
1515

1616
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1717
# patches here are for enabling the conversion webhook for each CRD

config/crd/patches/service_binding_annotations.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: dbaasconnections.dbaas.redhat.com
5+
labels:
6+
servicebinding.io/provisioned-service: "true"

controllers/dbaasconnection_controller_test.go

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,9 @@ var _ = Describe("DBaaSConnection controller - nominal", func() {
406406
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
407407
},
408408
},
409-
CredentialsRef: &v1.LocalObjectReference{
409+
Binding: &v1.LocalObjectReference{
410410
Name: testSecret.Name,
411411
},
412-
ConnectionInfoRef: &v1.LocalObjectReference{
413-
Name: "testConnectionInfoRef",
414-
},
415412
}
416413
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
417414
})
@@ -601,12 +598,9 @@ var _ = Describe("DBaaSConnection controller - nominal with instance reference",
601598
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
602599
},
603600
},
604-
CredentialsRef: &v1.LocalObjectReference{
601+
Binding: &v1.LocalObjectReference{
605602
Name: testSecret.Name,
606603
},
607-
ConnectionInfoRef: &v1.LocalObjectReference{
608-
Name: "testConnectionInfoRef",
609-
},
610604
}
611605
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
612606
})
@@ -702,12 +696,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() {
702696
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
703697
},
704698
},
705-
CredentialsRef: &v1.LocalObjectReference{
699+
Binding: &v1.LocalObjectReference{
706700
Name: testSecret.Name,
707701
},
708-
ConnectionInfoRef: &v1.LocalObjectReference{
709-
Name: "testConnectionInfoRef",
710-
},
711702
}
712703
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
713704
})
@@ -809,12 +800,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() {
809800
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
810801
},
811802
},
812-
CredentialsRef: &v1.LocalObjectReference{
803+
Binding: &v1.LocalObjectReference{
813804
Name: testSecret.Name,
814805
},
815-
ConnectionInfoRef: &v1.LocalObjectReference{
816-
Name: "testConnectionInfoRef",
817-
},
818806
}
819807
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
820808
})
@@ -934,12 +922,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() {
934922
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
935923
},
936924
},
937-
CredentialsRef: &v1.LocalObjectReference{
925+
Binding: &v1.LocalObjectReference{
938926
Name: testSecret.Name,
939927
},
940-
ConnectionInfoRef: &v1.LocalObjectReference{
941-
Name: "testConnectionInfoRef",
942-
},
943928
}
944929
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
945930
})
@@ -1045,12 +1030,9 @@ var _ = Describe("DBaaSConnection controller - valid dev namespaces", func() {
10451030
LastTransitionTime: metav1.Time{Time: lastTransitionTime},
10461031
},
10471032
},
1048-
CredentialsRef: &v1.LocalObjectReference{
1033+
Binding: &v1.LocalObjectReference{
10491034
Name: testSecret.Name,
10501035
},
1051-
ConnectionInfoRef: &v1.LocalObjectReference{
1052-
Name: "testConnectionInfoRef",
1053-
},
10541036
}
10551037
It("should update DBaaSConnection status", assertDBaaSResourceProviderStatusUpdated(createdDBaaSConnection, metav1.ConditionTrue, testConnectionKind, status))
10561038
})

test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ spec:
7070
status:
7171
description: DBaaSConnectionStatus defines the observed state of DBaaSConnection
7272
properties:
73+
binding:
74+
description: 'Binding exposes a secret containing the binding information
75+
for the instance. It implements the service binding Provisioned
76+
Service duck type. See: https://github.com/servicebinding/spec#provisioned-service'
77+
properties:
78+
name:
79+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
80+
TODO: Add other useful fields. apiVersion, kind, uid?'
81+
type: string
82+
type: object
7383
conditions:
7484
items:
7585
description: "Condition contains details for one aspect of the current
@@ -139,16 +149,6 @@ spec:
139149
- type
140150
type: object
141151
type: array
142-
connectionInfoRef:
143-
properties:
144-
name:
145-
type: string
146-
type: object
147-
credentialsRef:
148-
properties:
149-
name:
150-
type: string
151-
type: object
152152
type: object
153153
type: object
154154
served: true

test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ spec:
7474
status:
7575
description: DBaaSConnectionStatus defines the observed state of DBaaSConnection
7676
properties:
77+
binding:
78+
description: 'Binding exposes a secret containing the binding information
79+
for the instance. It implements the service binding Provisioned
80+
Service duck type. See: https://github.com/servicebinding/spec#provisioned-service'
81+
properties:
82+
name:
83+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
84+
TODO: Add other useful fields. apiVersion, kind, uid?'
85+
type: string
86+
type: object
7787
conditions:
7888
items:
7989
description: "Condition contains details for one aspect of the current
@@ -143,16 +153,6 @@ spec:
143153
- type
144154
type: object
145155
type: array
146-
connectionInfoRef:
147-
properties:
148-
name:
149-
type: string
150-
type: object
151-
credentialsRef:
152-
properties:
153-
name:
154-
type: string
155-
type: object
156156
type: object
157157
type: object
158158
served: true

0 commit comments

Comments
 (0)