Skip to content

Commit

Permalink
DBAAS-831: update DBaaSConnection status to conform to the Provisione…
Browse files Browse the repository at this point in the history
…d Service ducktype defined in the Service Binding Specification for Kubernetes
  • Loading branch information
xieshenzh committed Oct 14, 2022
1 parent d4fa962 commit 018ac59
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 102 deletions.
9 changes: 4 additions & 5 deletions api/v1alpha1/dbaasprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 12 additions & 20 deletions bundle/manifests/dbaas.redhat.com_dbaasconnections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 10 additions & 18 deletions config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions config/crd/patches/service_binding_annotations.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions config/crd/patches/service_binding_labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: dbaasconnections.dbaas.redhat.com
labels:
servicebinding.io/provisioned-service: "true"
30 changes: 6 additions & 24 deletions controllers/dbaasconnection_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
Expand Down Expand Up @@ -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))
})
Expand Down Expand Up @@ -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))
})
Expand Down Expand Up @@ -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))
})
Expand Down Expand Up @@ -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))
})
Expand Down Expand Up @@ -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))
})
Expand Down
20 changes: 10 additions & 10 deletions test/crd/dbaas.redhat.com_crunchybridgeconnections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions test/crd/dbaas.redhat.com_mongodbatlasconnections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 018ac59

Please sign in to comment.