env

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

README

env - Environment Variable Manager

The env middleware manages the handling of environment variables.

Arguments

It takes two arguments:

Save

The save argument is an optional string that causes the result of the pipe's execution to be stored in an environment variable of that name (excluding the $). The output is not swallowed, but still passed on as usual. This behavior might change in a future version of pipedream.

private:
    some-pipe:
        shell:
            run: "command"
        env:
            # the result of "command" will be saved in the environment as $ENV_VAR
            save: ENV_VAR
Interpolate

The interpolate argument is a string that determines how environment variables will be interpolated when the pipe is invoked. Possible values are: - deep: Values located within a nested map of arguments will be interpolated, irrespective of the level of nesting. - shallow: Only string values with a single level of nesting will be interpolated at invocation time. - none (default): No interpolation takes place at invocation time.

Note that environment variables that are not interpolated by the env middleware may still be evaluated at execution time, e.g. by the shell middleware. For this reason, you will only need to use this feature if interpolation should take place before execution - for example, to make conditional execution (using the when middleware) dependent on the value of an environment variable.

private:
    some-pipe:
        env:
            # added for clarity, `none` is the default value
            # note that using `deep` could cause problems here,
            # if the value of ENV_VAR is not yet set at the time of parent invocation
            interpolate: none
        pipe:
            - child-pipe:
                env:
                    interpolate: shallow
                # this value will be evaluated at child invocation time
                # note that if the value is set by another pipe,
                # the child's invocation must be delayed
                # until after the env var has been set
                # e.g. using the `waitFor` middleware
                when: "'$ENV_VAR' == 'YES!!'"

Documentation

Overview

Package env provides a middleware managing environment variables

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v0.32.2

type Middleware struct {
	Setenv    func(string, string) error
	ExpandEnv func(string) string
}

Middleware is an environment variable manager

func NewMiddleware added in v0.32.2

func NewMiddleware() Middleware

NewMiddleware creates a new middleware instance

func NewMiddlewareWithProvider added in v0.32.2

func NewMiddlewareWithProvider(
	setenv func(string, string) error,
	expandEnv func(string) string,
) Middleware

NewMiddlewareWithProvider creates a new middleware instance with the specified env functions

func (Middleware) Apply added in v0.32.2

func (envMiddleware Middleware) Apply(
	run *pipeline.Run,
	next func(*pipeline.Run),
	_ *middleware.ExecutionContext,
)

Apply is where the middleware's logic resides

It adapts the run based on its slice of the run's arguments. It may also trigger side effects such as executing shell commands or full runs of other pipelines. When done, this function should call next in order to continue unwinding the stack.

func (Middleware) String added in v0.32.2

func (envMiddleware Middleware) String() string

String is a human-readable description

Jump to

Keyboard shortcuts

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