runtime

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const KeyFuncIO contextKey = iota

KeyFuncIO is the key to the context value where the functionIO pointer is stored

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func AddToScheme

func AddToScheme(obj runtime.SchemeBuilder) error

AddToScheme adds given SchemeBuilder to the Scheme.

func Exec

func Exec(ctx context.Context, log logr.Logger, runtime *Runtime, transform Transform) error

Exec reads FunctionIO from stdin and return the desired state via transform function

func LogMetadata

func LogMetadata(c context.Context, a AppInfo) error

LogMetadata prints various metadata to the root logger. It prints version, architecture and current user ID and returns nil.

func NewZapLogger added in v1.0.0

func NewZapLogger(name, version string, verbosityLevel int, useProductionConfig bool) (logr.Logger, error)

func RunCommand

func RunCommand(ctx context.Context, input []byte, transforms []Transform) ([]byte, error)

Types

type AppInfo

type AppInfo struct {
	Version, Commit, Date, AppName, AppLongName string
}

AppInfo defines application information

type DesiredResources added in v1.0.0

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

func (*DesiredResources) Get added in v1.0.0

func (d *DesiredResources) Get(ctx context.Context, obj client.Object, resName string) error

Get unmarshalls the resource from the desired array. This will return any changes that a previous function has made to the desired array.

func (*DesiredResources) GetComposite added in v1.0.0

func (d *DesiredResources) GetComposite(_ context.Context, obj client.Object) error

GetComposite unmarshalls the desired composite from the function io to the given object.

func (*DesiredResources) GetCompositeConnectionDetails added in v1.0.0

func (d *DesiredResources) GetCompositeConnectionDetails(_ context.Context) []xfnv1alpha1.ExplicitConnectionDetail

GetCompositeConnectionDetails returns the connection details of the desired composite

func (*DesiredResources) GetFromObject added in v1.0.0

func (d *DesiredResources) GetFromObject(ctx context.Context, o client.Object, kon string) error

GetFromObject gets the k8s resource o from a provider kubernetes object kon (Kube Object Name) from the desired array of the FunctionIO.

func (*DesiredResources) List added in v1.0.0

List returns the list of managed resources from desired object

func (*DesiredResources) Put added in v1.0.0

Put adds the object as is to the FunctionIO desired array. It assumes that the given object is adheres to Crossplane's ManagedResource model.

func (*DesiredResources) PutCompositeConnectionDetail added in v1.0.0

func (d *DesiredResources) PutCompositeConnectionDetail(ctx context.Context, cd xfnv1alpha1.ExplicitConnectionDetail)

PutCompositeConnectionDetail appends a connection detail to the connection details slice of this desired composite

func (*DesiredResources) PutIntoObject added in v1.0.0

func (d *DesiredResources) PutIntoObject(ctx context.Context, o client.Object, kon string, refs ...xkube.Reference) error

PutIntoObject adds or updates the desired resource into its kube object

func (*DesiredResources) Remove added in v1.0.0

func (d *DesiredResources) Remove(ctx context.Context, name string) error

Remove removes a resource by name from the managed resources expect an error if resource not found

func (*DesiredResources) RemoveCompositeConnectionDetail added in v1.0.0

func (d *DesiredResources) RemoveCompositeConnectionDetail(ctx context.Context, cd xfnv1alpha1.ExplicitConnectionDetail) error

RemoveCompositeConnectionDetail removes a connection detail from the slice of connection details of this desired composite

func (*DesiredResources) SetComposite added in v1.0.0

func (d *DesiredResources) SetComposite(_ context.Context, obj client.Object) error

SetComposite sets a new desired composite to the function from the given object.

type ObservedResources added in v1.0.0

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

func (*ObservedResources) Get added in v1.0.0

func (o *ObservedResources) Get(ctx context.Context, obj client.Object, resName string) error

Get unmarshalls the managed resource with the given name into the given object. It reads from the Observed array.

func (*ObservedResources) GetComposite added in v1.0.0

func (o *ObservedResources) GetComposite(_ context.Context, obj client.Object) error

GetComposite unmarshalls the observed composite from the function io to the given object.

func (*ObservedResources) GetCompositeConnectionDetails added in v1.0.0

func (o *ObservedResources) GetCompositeConnectionDetails(_ context.Context) *[]xfnv1alpha1.ExplicitConnectionDetail

GetCompositeConnectionDetails returns the connection details of the observed composite

func (*ObservedResources) GetFromObject added in v1.0.0

func (o *ObservedResources) GetFromObject(ctx context.Context, obj client.Object, kon string) error

GetFromObject gets the k8s resource o from a provider kubernetes object kon (Kube Object Name) from the observed array of the FunctionIO.

func (*ObservedResources) List added in v1.0.0

List return the list of managed resources from observed object

type Resource added in v1.0.0

type Resource interface {
	GetName() string
	GetRaw() []byte
	SetRaw([]byte)
	// Returns this resource as a DesiredResource.
	// Depending on the concrete underlying type, not all fields are populated.
	GetDesiredResource() xfnv1alpha1.DesiredResource
	// Returns this resource as an ObservedResource.
	// Depending on the concrete underlying type, not all fields are populated.
	GetObservedResource() xfnv1alpha1.ObservedResource
}

type Result added in v1.0.0

type Result interface {
	Resolve() v1alpha1.Result
}

func NewFatal added in v1.0.0

func NewFatal(ctx context.Context, msg string) Result

NewFatal returns a fatal Result from a message string. The result is fatal, subsequent Composition Functions may run, but the Composition Function pipeline run will be considered a failure and the first error will be returned.

func NewFatalErr added in v1.0.0

func NewFatalErr(ctx context.Context, msg string, err error) Result

NewFatalErr returns a fatal Result from a message string and an error. The result is fatal, subsequent Composition Functions may run, but the Composition Function pipeline run will be considered a failure and the first error will be returned.

func NewNormal added in v1.0.0

func NewNormal() Result

NewNormal results are emitted as normal events and debug logs associated with the composite resource.

func NewWarning added in v1.0.0

func NewWarning(ctx context.Context, msg string) Result

NewWarning returns a warning Result from a message string. The entire Composition will run to completion but warning events and debug logs associated with the composite resource will be emitted.

type Runtime

type Runtime struct {
	Observed ObservedResources
	Desired  DesiredResources
	// contains filtered or unexported fields
}

Runtime a struct which encapsulates crossplane FunctionIO

func NewRuntime added in v1.0.0

func NewRuntime(ctx context.Context, input []byte) (*Runtime, error)

NewRuntime creates a new Runtime object.

type Transform

type Transform struct {
	Name          string
	TransformFunc func(c context.Context, io *Runtime) Result
}

Transform specifies a transformation function to be run against the given FunctionIO.

Jump to

Keyboard shortcuts

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