Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

A crossplane composition function generating random strings and inserting these at specified paths in composite resources

License

Notifications You must be signed in to change notification settings

23technologies/xp-fn-rndstr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

function-dummy

A Crossplane Composition Function that returns what you tell it to.

What is this?

This Composition Function generates random strings and inserts them into specified paths of a composition's resources. This is useful, when one needs to generate e.g. credentials for foreign infrastructure.

Here's an example:

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: test-xp-rndstr
spec:
  compositeTypeRef:
    apiVersion: database.example.com/v1alpha1
    kind: NoSQL
  pipeline:
    - step: patch-and-transform
      functionRef:
        name: function-patch-and-transform
      input:
        apiVersion: pt.fn.crossplane.io/v1beta1
        kind: Resources
        resources:
          - name: some-secret-for-password 
            base:
              apiVersion: kubernetes.crossplane.io/v1alpha1
              kind: Object
              spec:
                providerConfigRef:
                  name: provider-config-in-cluster
                forProvider:
                  manifest:
                    apiVersion: v1
                    kind: Secret
                    metadata:
                      namespace: default
                    stringData:
                      password: patchme
    - step: generate-openstack-password
      functionRef:
        name: xp-rndstr-func 
      input:
        apiVersion: randomstring.fn.23technologies.cloud
        kind: randString
        config:
          objects:
            - name: some-secret-for-password 
              fieldPath: "spec.forProvider.manifest.stringData.password"
          randomString:
            length: 10

Developing

This Function doesn't use the typical Crossplane build submodule and Makefile, since we'd like Functions to have a less heavyweight developer experience. It mostly relies on regular old Go tools:

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

# Run tests
$ go test -cover ./...
?       github.com/crossplane-contrib/function-dummy/input/v1beta1      [no test files]
ok      github.com/crossplane-contrib/function-dummy    0.006s  coverage: 25.8% of statements

# Lint the code
$ docker run --rm -v $(pwd):/app -v ~/.cache/golangci-lint/v1.54.2:/root/.cache -w /app golangci/golangci-lint:v1.54.2 golangci-lint run

# Build a Docker image - see Dockerfile
$ docker build .

This Function is pushed to xpkg.upbound.io/crossplane-contrib/function-dummy. At the time of writing it's pushed manually via docker push using docker-credential-up from https://github.com/upbound/up/.

About

A crossplane composition function generating random strings and inserting these at specified paths in composite resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published