Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLInstance connection secret extension and configuration enhancements #38

Merged
merged 7 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ build.init: $(UP)

# This target requires the following environment variables to be set:
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat gcp.json)
SKIP_DELETE ?=
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@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)
@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)
@$(OK) running automated tests

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

render:
Expand Down
63 changes: 54 additions & 9 deletions apis/composition.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xpostgresqlinstances.gcp.platform.upbound.io
name: xsqlinstances.gcp.platform.upbound.io
labels:
provider: gcp
spec:
Expand Down Expand Up @@ -94,31 +94,76 @@ spec:
string:
fmt: "%suser-%.8s" # mysql has a limit of 32 chars for users thus we need to limit the length
toFieldPath: metadata.annotations[crossplane.io/external-name]
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.uid
- fromFieldPath: spec.parameters.engine
strategy: string
string:
fmt: "%s-gcp-%s-user"
toFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
connectionDetails:
- name: username
type: FromFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
- name: password
type: FromConnectionSecretKey
fromConnectionSecretKey: attribute.password
- name: UpboundDatabase
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: Database
spec:
forProvider:
instanceSelector:
matchControllerRef: true
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: metadata.annotations[crossplane.io/external-name]
transforms:
- type: match
match:
fallbackValue: null
patterns:
- regexp: .*
result: upbound
type: regexp
- name: DBInstance
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: DatabaseInstance
spec:
forProvider:
databaseVersion: POSTGRES_13
deletionProtection: false
settings:
- diskSize: 20
tier: db-f1-micro
ipConfiguration:
- ipv4Enabled: false
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- fromFieldPath: metadata.uid
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.uid
- fromFieldPath: spec.parameters.engine
strategy: string
string:
fmt: "%s-gcp-%s"
toFieldPath: spec.writeConnectionSecretToRef.name
transforms:
- type: string
string:
type: Format
fmt: "%s-gcp-postgresql"
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- fromFieldPath: spec.parameters.storageGB
Expand All @@ -140,7 +185,7 @@ spec:
type: Convert
convert: "ToUpper"
connectionDetails:
- name: privateIP
- name: host
type: FromConnectionSecretKey
fromConnectionSecretKey: privateIP
- name: serverCACertificateCert
Expand Down
4 changes: 3 additions & 1 deletion apis/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ spec:
kind: SQLInstance
plural: sqlinstances
connectionSecretKeys:
- privateIP
- username
- password
- host
- serverCACertificateCert
versions:
- name: v1alpha1
Expand Down