diff --git a/Makefile b/Makefile index e405b43..d67171b 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/apis/composition.yaml b/apis/composition.yaml index 36721cb..6573d8d 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -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: @@ -94,17 +94,60 @@ 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 @@ -112,13 +155,15 @@ spec: 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 @@ -140,7 +185,7 @@ spec: type: Convert convert: "ToUpper" connectionDetails: - - name: privateIP + - name: host type: FromConnectionSecretKey fromConnectionSecretKey: privateIP - name: serverCACertificateCert diff --git a/apis/definition.yaml b/apis/definition.yaml index 548f5b7..854c2c3 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -11,7 +11,9 @@ spec: kind: SQLInstance plural: sqlinstances connectionSecretKeys: - - privateIP + - username + - password + - host - serverCACertificateCert versions: - name: v1alpha1