function-switcher

command module
v0.0.0-...-b06a4bd Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 13 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-switcher

CI

Function Switcher is a Crossplane function that enables Composition users to enable or disable creation of resources, without update schema of XRD, just using annotations like in on this example:

apiVersion: example.crossplane.io/v1
kind: XR
metadata:
  name: example-xr
  annotations:
    ## Annotations for enable/disable resources of Composition.
    switcher.fn.kndp.io/disabled: "resourceTwo,resourceThree"
    switcher.fn.kndp.io/enabled: "resourceOne"
spec:
  resourceOne:
    field1: "one"
    field2: "two"
  resourceTwo:
    field1: "three"
    field2: "four"
  resourceThree:
    field1: "five"
    field2: "six"

Installation:

  1. Create function using function package from registry:
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
  name: function-switcher
spec:
  package: xpkg.upbound.io/kndp/function-switcher:v0.0.1
  1. Setup function required to add it after resources generation function like function-patch-and-transform:
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: function-switcher
spec:
  mode: Pipeline
  pipeline:
  - step: patch-and-transform
    functionRef:
      name: function-patch-and-transform
    input:
      apiVersion: pt.fn.crossplane.io/v1beta1
      kind: Resources
      resources:

      - name: resourceOne
        base:
          apiVersion: example.crossplane.io/v1
          kind: Resource
          spec:
            field1: ""
            field2: ""
        patches:
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceOne.field1"
            toFieldPath: "spec.field1"
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceOne.field2"
            toFieldPath: "spec.field2"

      - name: resourceTwo
        base:
          apiVersion: example.crossplane.io/v1
          kind: Resource
          spec:
            field1: ""
            field2: ""
        patches:
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceTwo.field1"
            toFieldPath: "spec.field1"
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceTwo.field2"
            toFieldPath: "spec.field2"

      - name: resourceThree
        base:
          apiVersion: example.crossplane.io/v1
          kind: Resource
          spec:
            field1: ""
            field2: ""
        patches:
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceThree.field1"
            toFieldPath: "spec.field1"
          - type: FromCompositeFieldPath
            fromFieldPath: "spec.resourceThree.field2"
            toFieldPath: "spec.field2"
  ## Enable or disable resources from previous step
  - step: enable-disable
    functionRef:
      name: function-switcher

  compositeTypeRef:
    apiVersion: example.crossplane.io/v1
    kind: XR

Documentation

Overview

Package main implements a Composition Function.

Jump to

Keyboard shortcuts

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