xp-fn-rndstr

command module
v0.0.0-...-7b4adf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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/.

Documentation

Overview

Package main implements a Composition Function.

Directories

Path Synopsis
input
v1beta1
Package v1beta1 contains the input type for the Dummy Function +kubebuilder:object:generate=true +groupName=randomstring.fn.23technologies.cloud +versionName=v1beta1
Package v1beta1 contains the input type for the Dummy Function +kubebuilder:object:generate=true +groupName=randomstring.fn.23technologies.cloud +versionName=v1beta1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址