Skip to content

Commit

Permalink
feat(initial): add composition (#1)
Browse files Browse the repository at this point in the history
* feat(initial): add composition

Signed-off-by: Christopher Haar <[email protected]>

* feat(gcp): add uptest gcp project variable

Signed-off-by: Christopher Haar <[email protected]>

---------

Signed-off-by: Christopher Haar <[email protected]>
  • Loading branch information
haarchri authored Jan 19, 2024
1 parent 901fe43 commit 04f2a81
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 0 deletions.
82 changes: 82 additions & 0 deletions apis/default/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xnetworks.gcp.platform.upbound.io
labels:
provider: gcp
type: basic
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: gcp.platform.upbound.io/v1alpha1
kind: XNetwork
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: upbound-function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
patchSets:
- name: providerConfigRef
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- name: deletionPolicy
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
- name: region
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.region
resources:
- name: network
base:
apiVersion: compute.gcp.upbound.io/v1beta1
kind: Network
spec:
forProvider:
autoCreateSubnetworks: false
routingMode: REGIONAL
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.labels[networks.gcp.platform.upbound.io/network-id]

- name: subnetwork
base:
apiVersion: compute.gcp.upbound.io/v1beta1
kind: Subnetwork
spec:
forProvider:
ipCidrRange: 172.16.0.0/16
networkSelector:
matchControllerRef: true
privateIpGoogleAccess: true
secondaryIpRange:
- ipCidrRange: 10.200.0.0/14
rangeName: pods
- ipCidrRange: 10.204.0.0/16
rangeName: services
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.labels[networks.gcp.platform.upbound.io/network-id]
48 changes: 48 additions & 0 deletions apis/definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xnetworks.gcp.platform.upbound.io
spec:
group: gcp.platform.upbound.io
names:
kind: XNetwork
plural: xnetworks
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
parameters:
description: Network Parameters
properties:
id:
type: string
description: ID of this Network that other objects will use to refer to it.
region:
type: string
description: Region is the region you'd like your resource to be created in.
deletionPolicy:
description: When the Composition is deleted, delete the GCP resources. Defaults to Delete
enum:
- Delete
- Orphan
type: string
default: Delete
providerConfigName:
description: Crossplane ProviderConfig to use for provisioning this resources
type: string
default: default
required:
- deletionPolicy
- providerConfigName
- id
- region
type: object
required:
- parameters
6 changes: 6 additions & 0 deletions examples/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: configuration-gcp-network
spec:
package: xpkg.upbound.io/upbound/configuration-gcp-network:v0.1.0
6 changes: 6 additions & 0 deletions examples/function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: upbound-function-patch-and-transform
spec:
package: xpkg.upbound.io/upbound/function-patch-and-transform:v0.2.1
8 changes: 8 additions & 0 deletions examples/network-xr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: gcp.platform.upbound.io/v1alpha1
kind: XNetwork
metadata:
name: ref-gcp-network
spec:
parameters:
id: ref-gcp-network-from-xr
region: us-west2
2 changes: 2 additions & 0 deletions test/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -aeuo pipefail

UPTEST_GCP_PROJECT=${UPTEST_GCP_PROJECT:-official-provider-testing}

echo "Running setup.sh"
echo "Waiting until all configurations are healthy/installed..."
"${KUBECTL}" wait configuration.pkg --all --for=condition=Healthy --timeout 5m
Expand Down

0 comments on commit 04f2a81

Please sign in to comment.