Skip to content

Commit f7b56a2

Browse files
authored
Merge pull request #38 from ytsarev/conn-secret-extension
SQLInstance connection secret extension and configuration enhancements
2 parents db4bc6b + b2c7f86 commit f7b56a2

File tree

3 files changed

+60
-11
lines changed

3 files changed

+60
-11
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ build.init: $(UP)
5959

6060
# This target requires the following environment variables to be set:
6161
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat gcp.json)
62+
SKIP_DELETE ?=
6263
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
6364
@$(INFO) running automated tests
64-
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/network-xr.yaml,examples/postgres-claim.yaml,examples/mysql-claim.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
65+
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/network-xr.yaml,examples/postgres-claim.yaml,examples/mysql-claim.yaml --setup-script=test/setup.sh --default-timeout=2400 $(SKIP_DELETE) || $(FAIL)
6566
@$(OK) running automated tests
6667

6768
# This target requires the following environment variables to be set:
6869
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat gcp.json)
6970
# make e2e UPTEST_GCP_PROJECT=crossplane-playground to use a different project
71+
# Use `make e2e SKIP_DELETE=--skip-delete` to skip deletion of resources created during the test.
7072
e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest
7173

7274
render:

apis/composition.yaml

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apiextensions.crossplane.io/v1
22
kind: Composition
33
metadata:
4-
name: xpostgresqlinstances.gcp.platform.upbound.io
4+
name: xsqlinstances.gcp.platform.upbound.io
55
labels:
66
provider: gcp
77
spec:
@@ -94,31 +94,76 @@ spec:
9494
string:
9595
fmt: "%suser-%.8s" # mysql has a limit of 32 chars for users thus we need to limit the length
9696
toFieldPath: metadata.annotations[crossplane.io/external-name]
97+
- type: CombineFromComposite
98+
combine:
99+
variables:
100+
- fromFieldPath: metadata.uid
101+
- fromFieldPath: spec.parameters.engine
102+
strategy: string
103+
string:
104+
fmt: "%s-gcp-%s-user"
105+
toFieldPath: spec.writeConnectionSecretToRef.name
106+
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
107+
toFieldPath: spec.writeConnectionSecretToRef.namespace
108+
connectionDetails:
109+
- name: username
110+
type: FromFieldPath
111+
fromFieldPath: metadata.annotations[crossplane.io/external-name]
112+
- name: password
113+
type: FromConnectionSecretKey
114+
fromConnectionSecretKey: attribute.password
115+
- name: UpboundDatabase
116+
base:
117+
apiVersion: sql.gcp.upbound.io/v1beta1
118+
kind: Database
119+
spec:
120+
forProvider:
121+
instanceSelector:
122+
matchControllerRef: true
123+
patches:
124+
- type: PatchSet
125+
patchSetName: providerConfigRef
126+
- type: PatchSet
127+
patchSetName: deletionPolicy
128+
- type: FromCompositeFieldPath
129+
fromFieldPath: metadata.name
130+
toFieldPath: metadata.annotations[crossplane.io/external-name]
131+
transforms:
132+
- type: match
133+
match:
134+
fallbackValue: null
135+
patterns:
136+
- regexp: .*
137+
result: upbound
138+
type: regexp
97139
- name: DBInstance
98140
base:
99141
apiVersion: sql.gcp.upbound.io/v1beta1
100142
kind: DatabaseInstance
101143
spec:
102144
forProvider:
103-
databaseVersion: POSTGRES_13
104145
deletionProtection: false
105146
settings:
106147
- diskSize: 20
107148
tier: db-f1-micro
149+
ipConfiguration:
150+
- ipv4Enabled: false
108151
patches:
109152
- type: PatchSet
110153
patchSetName: providerConfigRef
111154
- type: PatchSet
112155
patchSetName: deletionPolicy
113156
- type: PatchSet
114157
patchSetName: region
115-
- fromFieldPath: metadata.uid
158+
- type: CombineFromComposite
159+
combine:
160+
variables:
161+
- fromFieldPath: metadata.uid
162+
- fromFieldPath: spec.parameters.engine
163+
strategy: string
164+
string:
165+
fmt: "%s-gcp-%s"
116166
toFieldPath: spec.writeConnectionSecretToRef.name
117-
transforms:
118-
- type: string
119-
string:
120-
type: Format
121-
fmt: "%s-gcp-postgresql"
122167
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
123168
toFieldPath: spec.writeConnectionSecretToRef.namespace
124169
- fromFieldPath: spec.parameters.storageGB
@@ -140,7 +185,7 @@ spec:
140185
type: Convert
141186
convert: "ToUpper"
142187
connectionDetails:
143-
- name: privateIP
188+
- name: host
144189
type: FromConnectionSecretKey
145190
fromConnectionSecretKey: privateIP
146191
- name: serverCACertificateCert

apis/definition.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ spec:
1111
kind: SQLInstance
1212
plural: sqlinstances
1313
connectionSecretKeys:
14-
- privateIP
14+
- username
15+
- password
16+
- host
1517
- serverCACertificateCert
1618
versions:
1719
- name: v1alpha1

0 commit comments

Comments
 (0)