Skip to content

jbw976/function-v2-test

Repository files navigation

function-v2-test

A function for testing function-sdk-go v2 compatibility as part of crossplane/function-sdk-go#226.

The function takes a few pieces of input:

  • From the XR:
    • a list of names of ConfigMap resources to compose
    • a data value to save in each ConfigMap
  • From the Composition pipeline step .input
    • the name of the data key to use in the each ConfigMap

Given the following example XR from the example folder:

apiVersion: v2.test.crossplane.io/v1
kind: CoolXR
metadata:
  name: example-xr
spec:
  dataValue: "cool-value"
  names:
  - "cool-cm-1"
  - "cool-cm-2"

And Composition snippet:

...
    input:
      apiVersion: template.fn.crossplane.io/v1beta1
      kind: Input
      keyName: "cool-key"

This function will compose the following desired resources:

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    crossplane.io/composite: example-xr
  name: cool-cm-1
  namespace: default
data:
  cool-key: cool-value
---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    crossplane.io/composite: example-xr
  name: cool-cm-2
  namespace: default
data:
  cool-key: cool-value

Development

# Run code generation - see input/generate.go
$ go generate ./...

# Run tests - see fn_test.go
$ go test ./...
# Build the function's runtime image - see Dockerfile
docker build . --quiet --platform=linux/amd64 --tag runtime-amd64
docker build . --quiet --platform=linux/arm64 --tag runtime-arm64
# Build a function package - see package/crossplane.yaml
crossplane xpkg build \
    --package-root=package \
    --embed-runtime-image=runtime-amd64 \
    --package-file=function-amd64.xpkg
crossplane xpkg build \
    --package-root=package \
    --embed-runtime-image=runtime-arm64 \
    --package-file=function-arm64.xpkg
# Push the function package to a registry
crossplane xpkg push \
  --package-files=function-amd64.xpkg,function-arm64.xpkg \
  xpkg.upbound.io/jaredorg/function-v2-test:v0.0.2

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors