runtime

package
v4.43.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is the errur returned, if the requested resource is not in the
	// the given function state (desired,observed).
	ErrNotFound = errors.New("not found")
)

Functions

func NewFatalResult added in v4.43.0

func NewFatalResult(err error) *xfnproto.Result

NewFatalResult creates a new result with the `FATAL` severity. The pipeline will be considdered failed.

func NewNormalResult added in v4.43.0

func NewNormalResult(message string) *xfnproto.Result

NewNormalResult creates a new resul with the `NORMAL` severity.

func NewWarningResult added in v4.43.0

func NewWarningResult(message string) *xfnproto.Result

NewWarningResult will return a new warning. The pipelines will run through and are not considdered failed.

func RegisterService added in v4.43.0

func RegisterService(name string, function Service)

RegisterService will register a service to the map of all services.

Types

type Manager added in v4.43.0

type Manager struct {
	fnv1beta1.UnimplementedFunctionRunnerServiceServer
	// contains filtered or unexported fields
}

Manager manages all services and their steps. It also provides a proxy mode to offload any service to another GRPC endpoint.

func NewManager added in v4.43.0

func NewManager(log logr.Logger, proxyMode bool) *Manager

NewManager creates a new manager.

func (Manager) RunFunction added in v4.43.0

RunFunction implements the crossplane composition function `FunctionRunnerServiceServer` interface.

type Service added in v4.43.0

type Service struct {
	Steps []Step
}

Service contains all steps necessary to provide the service (except the legacy P+T portion).

type ServiceRuntime added in v4.43.0

type ServiceRuntime struct {
	Log logr.Logger

	Config corev1.ConfigMap
	// contains filtered or unexported fields
}

ServiceRuntime holds the state for one given service. It keeps track of the changes that each step does. The actual response will be assembled at the end.

func NewServiceRuntime added in v4.43.0

func NewServiceRuntime(l logr.Logger, config corev1.ConfigMap, req *fnv1beta1.RunFunctionRequest) (*ServiceRuntime, error)

NewServiceRuntime returns a new runtime for a given service.

func (*ServiceRuntime) AddObservedConnectionDetails added in v4.43.0

func (s *ServiceRuntime) AddObservedConnectionDetails(name string) error

AddObservedConnectionDetails will add all of the observed connection details of the given resouce to the composite's connection details.

func (*ServiceRuntime) AddResult added in v4.43.0

func (s *ServiceRuntime) AddResult(result *xfnproto.Result)

AddResult will add any result the the list of results

func (*ServiceRuntime) GetAllDesired added in v4.43.0

func (s *ServiceRuntime) GetAllDesired() map[resource.Name]*resource.DesiredComposed

GetAllDesired returns a map of all observed resources. This is useful when a function needs to have overview about all objects belonging to a service.

func (*ServiceRuntime) GetAllObserved added in v4.43.0

func (s *ServiceRuntime) GetAllObserved() (map[resource.Name]resource.ObservedComposed, error)

GetAllObserved returns a map of all observed resources. This is useful when a function needs to have overview about all objects belonging to a service.

func (*ServiceRuntime) GetBoolFromCompositionConfig added in v4.43.0

func (s *ServiceRuntime) GetBoolFromCompositionConfig(key string) bool

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

func (*ServiceRuntime) GetConnectionDetails added in v4.43.0

func (s *ServiceRuntime) GetConnectionDetails() map[string][]byte

GetConnectionDetails returns all current connection details for the current composite.

func (*ServiceRuntime) GetDesiredComposedResourceByName added in v4.43.0

func (s *ServiceRuntime) GetDesiredComposedResourceByName(obj xpresource.Managed, name string) error

GetDesiredComposedResourceByName will return a desired composed resource from the request. Use this, if you want anything from a previous function in the pipeline.

func (*ServiceRuntime) GetDesiredComposite added in v4.43.0

func (s *ServiceRuntime) GetDesiredComposite(obj client.Object) error

GetDesiredComposite will return the currently desired composite. The only differences from the observed composite will be either in metadata or the status. As Crossplane 1.14 composition function forbid any changes other than those fields.

func (*ServiceRuntime) GetDesiredKubeObject added in v4.43.0

func (s *ServiceRuntime) GetDesiredKubeObject(obj client.Object, name string) error

GetDesiredKubeObject returns the object as is on the cluster.

func (*ServiceRuntime) GetObservedComposedResource added in v4.43.0

func (s *ServiceRuntime) GetObservedComposedResource(obj xpresource.Managed, name string) error

GetObservedComposedResource returns and unmarshals the observed object into the given managed resource.

func (*ServiceRuntime) GetObservedComposedResourceConnectionDetails added in v4.43.0

func (s *ServiceRuntime) GetObservedComposedResourceConnectionDetails(objectName string) (map[string][]byte, error)

GetObservedComposedResourceConnectionDetails returns the observed connection details of the given composed resource. Returns an empty map if not found.

func (*ServiceRuntime) GetObservedComposite added in v4.43.0

func (s *ServiceRuntime) GetObservedComposite(obj client.Object) error

GetObservedComposite returns the observed composite and unmarshals it into the given object.

func (*ServiceRuntime) GetObservedKubeObject added in v4.43.0

func (s *ServiceRuntime) GetObservedKubeObject(obj client.Object, name string) error

GetObservedKubeObject returns the object as is on the cluster.

func (*ServiceRuntime) GetRequest added in v4.43.0

func (s *ServiceRuntime) GetRequest() *fnv1beta1.RunFunctionRequest

GetRequest returns the pointer to the request.

func (*ServiceRuntime) GetResponse added in v4.43.0

func (s *ServiceRuntime) GetResponse() (*fnv1beta1.RunFunctionResponse, error)

GetResponse returns the response with all desired resources set. This is the raw GRPC response for crossplane. If at any time s.SetRespones() was called, then this function will return the set response.

func (*ServiceRuntime) SetConnectionDetail added in v4.43.0

func (s *ServiceRuntime) SetConnectionDetail(name string, value []byte)

SetConnectionDetail will add the given name/value pair to the map containing all desired connection details of the composite. Be careful to not override existing keys.

func (*ServiceRuntime) SetDesiredComposedResource added in v4.43.0

func (s *ServiceRuntime) SetDesiredComposedResource(obj xpresource.Managed) error

SetDesiredComposedResource adds the given object to the desired resources, it needs to be a proper crossplane Managed Resource.

func (*ServiceRuntime) SetDesiredComposedResourceWithName added in v4.43.0

func (s *ServiceRuntime) SetDesiredComposedResourceWithName(obj xpresource.Managed, name string) error

SetDesiredComposedResourceWithName adds the given object to the desired resources, it needs to be a proper crossplane Managed Resource. Additionally provide a name, if it's not derived from the object name. Usually needed for objects that where migrated from P+T compositions with a static name.

func (*ServiceRuntime) SetDesiredCompositeStatus added in v4.43.0

func (s *ServiceRuntime) SetDesiredCompositeStatus(obj client.Object) error

SetDesiredCompositeStatus takes the given composite and updates the status accordingly. All other fields will not be updated by crossplane.

func (*ServiceRuntime) SetDesiredKubeObject added in v4.43.0

func (s *ServiceRuntime) SetDesiredKubeObject(obj client.Object, objectName string, refs ...xkube.Reference) error

SetDesiredKubeObject takes any `runtime.Object`, puts it into a provider-kubernetes Object and then adds it to the desired composed resources.

func (*ServiceRuntime) SetDesiredKubeObjectWithName added in v4.43.0

func (s *ServiceRuntime) SetDesiredKubeObjectWithName(obj client.Object, objectName, resourceName string, refs ...xkube.Reference) error

SetDesiredKubeObjectWithName takes any `runtime.Object`, puts it into a provider-kubernetes Object and then adds it to the desired composed resources with the specified resource name. This should be used if manipulating objects that are declared in the P+T composition.

func (*ServiceRuntime) SetDesiredKubeObserveObject added in v4.43.0

func (s *ServiceRuntime) SetDesiredKubeObserveObject(obj client.Object, objectName string, refs ...xkube.Reference) error

SetDesiredKubeObserveObject takes any `runtime.Object`, puts it into a provider-kubernetes Object and then adds it to the desired composed resources.

func (*ServiceRuntime) SetResponse added in v4.43.0

func (s *ServiceRuntime) SetResponse(resp *fnv1beta1.RunFunctionResponse)

SetResponse directly sets the response for the service. Please only use this if the service has one single step.

type Step added in v4.43.0

type Step struct {
	Name    string
	Execute func(context.Context, *ServiceRuntime) *xfnproto.Result
}

Step describes a single change within a service. It's essentially what was previously called a TransformFunc.

Jump to

Keyboard shortcuts

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