runtime

package
v4.20.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: BSD-3-Clause Imports: 17 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, runtime *Runtime, transform Transform) error

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

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

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

func (*DesiredResources) Get

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

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

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

GetCompositeConnectionDetails returns the connection details of the desired composite

func (*DesiredResources) GetFromObject

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

List returns the list of managed resources from desired object

func (*DesiredResources) Put

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

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

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, from docs:

The provider can fully manage the resource.

func (*DesiredResources) PutIntoObserveOnlyObject

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

PutIntoObserveOnlyObject adds or updates the desired resource into its OBSERVE-ONLY kube object, from docs: PutIntoObject adds or updates the desired resource into its OBSERVE-ONLY kube object, from docs:

The provider can only observe the resource. This maps to the read-only scenario where
the resource is fully controlled by third party application. The provider reads the
resource manifest and stores in Object at status.atProvider.

func (*DesiredResources) PutWithResourceName

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

PutWithResourceName allows you to put the resource with a custom name into the desire array. This is useful to put back a resource that's already defined in the P+T composition.

func (*DesiredResources) Remove

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

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

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

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

func (*ObservedResources) Get

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

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

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

GetCompositeConnectionDetails returns the connection details of the observed composite

func (*ObservedResources) GetFromObject

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

List return the list of managed resources from observed object

type Resource

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

type Result interface {
	Resolve() v1alpha1.Result
}

func NewFatal

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

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

func NewNormal() Result

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

func NewWarning

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
	Config   *corev1.ConfigMap
	// contains filtered or unexported fields
}

Runtime a struct which encapsulates crossplane FunctionIO

func NewRuntime

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

NewRuntime creates a new Runtime object.

func (*Runtime) GetBootFromCompositionConfig

func (r *Runtime) GetBootFromCompositionConfig(key string) bool

GetBootFromCompositionConfig is a small function to help us retrieve bool values from configMap

func (*Runtime) GetRawFuncIO

func (r *Runtime) GetRawFuncIO() *xfnv1alpha1.FunctionIO

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