ref

package
v1.2.0-rc Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor processes ref value to a string

func NewProcessor

func NewProcessor(wfr *v1alpha1.WorkflowRun, getter SecretGetter) *Processor

NewProcessor creates a processor object

func (*Processor) ResolveRefStringValue

func (p *Processor) ResolveRefStringValue(ref string) (string, error)

ResolveRefStringValue resolves a ref kind value, if it's not a ref value, return the origin value. Valid ref values supported now include: - '${secrets.<ns>:<secret>/<jsonpath>/...}' to refer value in a secret - '${stages.<stage>.outputs.<key>}' to refer value from a stage output - '${variables.<key>}' to refer value from a global variable defined in wfr

type SecretGetter added in v1.2.0

type SecretGetter = func(namespace, name string) (*corev1.Secret, error)

SecretGetter is used to get a secret from the cluster. The reason we use SecretGetter here is to decouple from the kubernetes clientset.

type SecretRefValue

type SecretRefValue struct {
	// Namespace of the secret
	Namespace string
	// Name of the secret
	Secret string
	// Json path in the secret to refer the value. If more than one
	// paths provided, value resolved for the previous path would be
	// regarded as a marshaled json and be used as data source to the
	// following one.
	Jsonpaths []string
}

SecretRefValue represents a value in a secret. It's defined by a secret and json paths.

func NewSecretRefValue

func NewSecretRefValue() *SecretRefValue

NewSecretRefValue create a secret reference value.

func (*SecretRefValue) Parse

func (r *SecretRefValue) Parse(ref string) error

Parse parses a given ref. The reference value specifies json path in a secret. Format of the reference is: ${secrets.<namespace>:<secret-name>/<jsonpath>/<jsonpath>} For example, in secret (named 'secret' under namespace 'ns'):

{
  "apiVersion": "v1",
  "data": {
   "key": "KEY",
   "json": "{\"user\":{\"id\": \"111\"}}"
  },
  "kind": "Secret",
  "type": "Opaque",
  "metadata": {
      ...
  }
}

${secrets.ns:secret/data.key} --> KEY ${secrets.ns:secret/data.json/user.id} --> 111

func (*SecretRefValue) Resolve

func (r *SecretRefValue) Resolve(secretGetter SecretGetter) (string, error)

Resolve resolves the secret ref and get the real value.

type VariableRefValue

type VariableRefValue struct {

	// Name of the variable
	Name string
	// contains filtered or unexported fields
}

VariableRefValue represents a global(wfr scope) variable value. It's defined in wfr spec.globalVariables.

func NewVariableRefValue

func NewVariableRefValue(wfr *v1alpha1.WorkflowRun) *VariableRefValue

NewVariableRefValue create a variable reference value.

func (*VariableRefValue) Parse

func (r *VariableRefValue) Parse(ref string) error

Parse parses a given ref. The reference value specifies variable key defined in wfr. Format of the reference is: ${variables.<key>}

For example, in wfr (named 'secret' under namespace 'ns'):

{
  "kind": "WorkflowRun",
  ...
  "spec": {
    "globalVariables": [
      {
        "IMAGE": "cyclone"
      },
      {
        "Registry": "docker.io"
      }
    ]
  }
}

${variables.IMAGE} --> cyclone ${variables.Registry} --> docker.io

func (*VariableRefValue) Resolve

func (r *VariableRefValue) Resolve() (string, error)

Resolve resolves the variable ref and get the real value.

Jump to

Keyboard shortcuts

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