...

Package runtimeutil

import "sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
Overview
Index

Overview ▾

Package runtimeutil contains libraries for implementing function runtimes.

Constants

const (
    FunctionAnnotationKey = "config.kubernetes.io/function"
)

type ContainerEnv

ContainerEnv defines the environment present in a container.

type ContainerEnv struct {
    // EnvVars is a key-value map that will be set as env in container
    EnvVars map[string]string

    // VarsToExport are only env key. Value will be the value in the host system
    VarsToExport []string
}

func NewContainerEnv

func NewContainerEnv() *ContainerEnv

NewContainerEnv returns a pointer to a new ContainerEnv

func NewContainerEnvFromStringSlice

func NewContainerEnvFromStringSlice(envStr []string) *ContainerEnv

NewContainerEnvFromStringSlice returns a new ContainerEnv pointer with parsing input envStr. envStr example: ["foo=bar", "baz"]

func (*ContainerEnv) AddKey

func (ce *ContainerEnv) AddKey(key string)

AddKey adds a key into the envs

func (*ContainerEnv) AddKeyValue

func (ce *ContainerEnv) AddKeyValue(key, value string)

AddKeyValue adds a key-value pair into the envs

func (*ContainerEnv) GetDockerFlags

func (ce *ContainerEnv) GetDockerFlags() []string

GetDockerFlags returns docker run style env flags

func (*ContainerEnv) HasExportedKey

func (ce *ContainerEnv) HasExportedKey(key string) bool

HasExportedKey returns true if the key is a exported key

func (*ContainerEnv) Raw

func (ce *ContainerEnv) Raw() []string

Raw returns a slice of string which represents the envs. Example: [foo=bar, baz]

type ContainerNetworkName

ContainerNetworkName is a type for network name used in container

type ContainerNetworkName string
const (
    NetworkNameNone ContainerNetworkName = "none"
    NetworkNameHost ContainerNetworkName = "host"
)

type ContainerSpec

ContainerSpec defines a spec for running a function as a container

type ContainerSpec struct {
    // Image is the container image to run
    Image string `json:"image,omitempty" yaml:"image,omitempty"`

    // Network defines network specific configuration
    Network bool `json:"network,omitempty" yaml:"network,omitempty"`

    // Mounts are the storage or directories to mount into the container
    StorageMounts []StorageMount `json:"mounts,omitempty" yaml:"mounts,omitempty"`

    // Env is a slice of env string that will be exposed to container
    Env []string `json:"envs,omitempty" yaml:"envs,omitempty"`
}

type DeferFailureFunction

type DeferFailureFunction interface {
    GetExit() error
}

type ExecSpec

type ExecSpec struct {
    Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

type FunctionFilter

FunctionFilter wraps another filter to be invoked in the context of a function. FunctionFilter manages scoping the function, deferring failures, and saving results to files.

type FunctionFilter struct {
    // Run implements the function.
    Run func(reader io.Reader, writer io.Writer) error

    // FunctionConfig is passed to the function through ResourceList.functionConfig.
    FunctionConfig *yaml.RNode `yaml:"functionConfig,omitempty"`

    // GlobalScope explicitly scopes the function to all input resources rather than only those
    // resources scoped to it by path.
    GlobalScope bool

    // ResultsFile is the file to write function ResourceList.results to.
    // If unset, results will not be written.
    ResultsFile string

    // DeferFailure will cause the Filter to return a nil error even if Run returns an error.
    // The Run error will be available through GetExit().
    DeferFailure bool

    // results saves the results emitted from Run
    Results *yaml.RNode
    // contains filtered or unexported fields
}

func (*FunctionFilter) Filter

func (c *FunctionFilter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

func (FunctionFilter) GetExit

func (c FunctionFilter) GetExit() error

GetExit returns the error from Run

type FunctionSpec

FunctionSpec defines a spec for running a function

type FunctionSpec struct {
    DeferFailure bool `json:"deferFailure,omitempty" yaml:"deferFailure,omitempty"`

    // Container is the spec for running a function as a container
    Container ContainerSpec `json:"container,omitempty" yaml:"container,omitempty"`

    // Starlark is the spec for running a function as a starlark script
    Starlark StarlarkSpec `json:"starlark,omitempty" yaml:"starlark,omitempty"`

    // ExecSpec is the spec for running a function as an executable
    Exec ExecSpec `json:"exec,omitempty" yaml:"exec,omitempty"`
}

func GetFunctionSpec

func GetFunctionSpec(n *yaml.RNode) (*FunctionSpec, error)

GetFunctionSpec returns the FunctionSpec for a resource. Returns nil if the resource does not have a FunctionSpec.

The FunctionSpec is read from the resource metadata.annotation "config.kubernetes.io/function"

type IsReconcilerFilter

IsReconcilerFilter filters Resources based on whether or not they are Reconciler Resource. Resources with an apiVersion starting with '*.gcr.io', 'gcr.io' or 'docker.io' are considered Reconciler Resources.

type IsReconcilerFilter struct {
    // ExcludeReconcilers if set to true, then Reconcilers will be excluded -- e.g.
    // Resources with a reconcile container through the apiVersion (gcr.io prefix) or
    // through the annotations
    ExcludeReconcilers bool `yaml:"excludeReconcilers,omitempty"`

    // IncludeNonReconcilers if set to true, the NonReconciler will be included.
    IncludeNonReconcilers bool `yaml:"includeNonReconcilers,omitempty"`
}

func (*IsReconcilerFilter) Filter

func (c *IsReconcilerFilter) Filter(inputs []*yaml.RNode) ([]*yaml.RNode, error)

Filter implements kio.Filter

type StarlarkSpec

StarlarkSpec defines how to run a function as a starlark program

type StarlarkSpec struct {
    Name string `json:"name,omitempty" yaml:"name,omitempty"`

    // Path specifies a path to a starlark script
    Path string `json:"path,omitempty" yaml:"path,omitempty"`

    // URL specifies a url containing a starlark script
    URL string `json:"url,omitempty" yaml:"url,omitempty"`
}

type StorageMount

StorageMount represents a container's mounted storage option(s)

type StorageMount struct {
    // Type of mount e.g. bind mount, local volume, etc.
    MountType string `json:"type,omitempty" yaml:"type,omitempty"`

    // Source for the storage to be mounted.
    // For named volumes, this is the name of the volume.
    // For anonymous volumes, this field is omitted (empty string).
    // For bind mounts, this is the path to the file or directory on the host.
    Src string `json:"src,omitempty" yaml:"src,omitempty"`

    // The path where the file or directory is mounted in the container.
    DstPath string `json:"dst,omitempty" yaml:"dst,omitempty"`

    // Mount in ReadWrite mode if it's explicitly configured
    // See https://docs.docker.com/storage/bind-mounts/#use-a-read-only-bind-mount
    ReadWriteMode bool `json:"rw,omitempty" yaml:"rw,omitempty"`
}

func StringToStorageMount

func StringToStorageMount(s string) StorageMount

func (*StorageMount) String

func (s *StorageMount) String() string