From 063e71f86cebdd3aacd3bdabc514f5aa09a429c3 Mon Sep 17 00:00:00 2001 From: peefy Date: Thu, 14 Mar 2024 20:10:26 +0800 Subject: [PATCH] chore: update local path examples Signed-off-by: peefy --- examples/resources/network/Makefile | 9 +++++++ examples/resources/network/composition.k | 27 +++++++++++++++++++ .../resources/network/local_composition.yaml | 24 +++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 examples/resources/network/composition.k create mode 100644 examples/resources/network/local_composition.yaml diff --git a/examples/resources/network/Makefile b/examples/resources/network/Makefile index f9a7429..30334ff 100644 --- a/examples/resources/network/Makefile +++ b/examples/resources/network/Makefile @@ -1,2 +1,11 @@ run: crossplane beta render xr.yaml composition.yaml functions.yaml -r + +oci: + crossplane beta render xr.yaml oci_composition.yaml functions.yaml -r + +git: + crossplane beta render xr.yaml git_composition.yaml functions.yaml -r + +local: + crossplane beta render xr.yaml local_composition.yaml functions.yaml -r diff --git a/examples/resources/network/composition.k b/examples/resources/network/composition.k new file mode 100644 index 0000000..c90e6a4 --- /dev/null +++ b/examples/resources/network/composition.k @@ -0,0 +1,27 @@ +# Get the XR spec fields +id = option("params")?.oxr?.spec.id or "" +# Render XR to crossplane managed resources +network_id_labels = {"networks.meta.fn.crossplane.io/network-id" = id} if id else {} +vpc = { + apiVersion = "ec2.aws.upbound.io/v1beta1" + kind = "VPC" + metadata.name = "vpc" + metadata.labels: network_id_labels + spec.forProvider = { + region = "eu-west-1" + cidrBlock = "192.168.0.0/16" + enableDnsSupport = True + enableDnsHostnames = True + } +} +gateway = { + apiVersion = "ec2.aws.upbound.io/v1beta1" + kind = "InternetGateway" + metadata.name = "gateway" + metadata.labels: network_id_labels + spec.forProvider = { + region = "eu-west-1" + vpcIdSelector.matchControllerRef = True + } +} +items = [vpc, gateway] diff --git a/examples/resources/network/local_composition.yaml b/examples/resources/network/local_composition.yaml new file mode 100644 index 0000000..e5d92ed --- /dev/null +++ b/examples/resources/network/local_composition.yaml @@ -0,0 +1,24 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: xlabels.fn-demo.crossplane.io + labels: + provider: aws +spec: + writeConnectionSecretsToNamespace: crossplane-system + compositeTypeRef: + apiVersion: fn-demo.crossplane.io/v1alpha1 + kind: XNetwork + mode: Pipeline + pipeline: + - step: normal + functionRef: + name: kcl-function + input: + apiVersion: krm.kcl.dev/v1alpha1 + kind: KCLRun + metadata: + name: basic + spec: + target: Resources + source: ./examples/resources/network/composition.k