runtimeutil

package
v0.10.15 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 17

Documentation

Overview

Package runtimeutil contains libraries for implementing function runtimes.

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerEnv added in v0.7.1

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
}

ContainerEnv defines the environment present in a container.

func NewContainerEnv added in v0.7.1

func NewContainerEnv() *ContainerEnv

NewContainerEnv returns a pointer to a new ContainerEnv

func NewContainerEnvFromStringSlice added in v0.7.1

func NewContainerEnvFromStringSlice(envStr []string) *ContainerEnv

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

func (*ContainerEnv) AddKey added in v0.7.1

func (ce *ContainerEnv) AddKey(key string)

AddKey adds a key into the envs

func (*ContainerEnv) AddKeyValue added in v0.7.1

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

AddKeyValue adds a key-value pair into the envs

func (*ContainerEnv) GetDockerFlags added in v0.7.1

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

GetDockerFlags returns docker run style env flags

func (*ContainerEnv) HasExportedKey added in v0.7.1

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

HasExportedKey returns true if the key is a exported key

func (*ContainerEnv) Raw added in v0.7.1

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

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

type ContainerNetworkName added in v0.7.0

type ContainerNetworkName string

ContainerNetworkName is a type for network name used in container

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

type ContainerSpec

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"`
}

ContainerSpec defines a spec for running a function as a container

type DeferFailureFunction

type DeferFailureFunction interface {
	GetExit() error
}

type ExecSpec

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

type FunctionFilter

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
	// contains filtered or unexported fields
}

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.

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

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"`

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

FunctionSpec defines a spec for running a function

func GetFunctionSpec

func GetFunctionSpec(n *yaml.RNode) *FunctionSpec

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

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"`
}

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.

func (*IsReconcilerFilter) Filter

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

Filter implements kio.Filter

type StarlarkSpec

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"`
}

StarlarkSpec defines how to run a function as a starlark program

type StorageMount

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"`
}

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

func StringToStorageMount

func StringToStorageMount(s string) StorageMount

func (*StorageMount) String

func (s *StorageMount) String() string

Jump to

Keyboard shortcuts

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