runtimeutil

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 12 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 ContainerNetwork

type ContainerNetwork struct {
	// Required specifies that function requires a network
	Required bool `json:"required,omitempty" yaml:"required,omitempty"`
}

ContainerNetwork

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

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 {
	// Network is the name of the network to use from a container
	Network string `json:"network,omitempty" yaml:"network,omitempty"`

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

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