runtime

package
v4.72.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OwnerKindAnnotation    = "appcat.vshn.io/ownerkind"
	OwnerVersionAnnotation = "appcat.vshn.io/ownerapiversion"
	OwnerGroupAnnotation   = "appcat.vshn.io/ownergroup"
)

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 KubeOptionObserveCreateUpdate added in v4.64.2

func KubeOptionObserveCreateUpdate(obj *xkube.Object)

KubeOptionObserveCreateUpdate sets the object to only create and update. Provider-kubernetes will not delete it.

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 KubeObjectOption added in v4.53.0

type KubeObjectOption func(obj *xkube.Object)

func KubeOptionAddConnectionDetails added in v4.53.0

func KubeOptionAddConnectionDetails(destNamespace string, cd ...xkube.ConnectionDetail) KubeObjectOption

KubeOptionAddConnectionDetails adds the given connection details to the kube object. DestNamespace speficies the namespace where the associated secret should be saved. The associated secret will have the UID of the parent object as the name.

func KubeOptionAddRefs added in v4.53.0

func KubeOptionAddRefs(refs ...xkube.Reference) KubeObjectOption

KubeOptionAddRefs adds the given references to the kube object.

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) DeleteDesiredCompososedResource added in v4.45.1

func (s *ServiceRuntime) DeleteDesiredCompososedResource(name string)

DeleteDesiredCompososedResource removes a composite resource from the desired objects. If the object is existing on the cluster, it will be deleted!

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 unmarshalls 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. Additionally it injects the claim-name, claim-namespace and the composite name as a label.

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, opts ...KubeObjectOption) error

SetDesiredKubeObject takes any `runtime.Object`, puts it into a provider-kubernetes Object and then adds it to the desired composed resources. It takes options to manipulate the resulting kubec object before applying.

func (*ServiceRuntime) SetDesiredKubeObjectWithName added in v4.43.0

func (s *ServiceRuntime) SetDesiredKubeObjectWithName(obj client.Object, objectName, resourceName string, opts ...KubeObjectOption) 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.

func (*ServiceRuntime) WaitForDependencies added in v4.53.0

func (s *ServiceRuntime) WaitForDependencies(mainResource string, dependencies ...string) bool

WaitForDependencies takes two arguments, the name of the main resource, which should be deployed after the dependencies. It also takes a list of names for objects to depend on. It does NOT deploy any objects, but check for their existence. If true is returned it is safe to continue with adding your main object to the desired resources. If the main resource already exists in the observed state it will always return true.

func (*ServiceRuntime) WaitForDependenciesWithConnectionDetails added in v4.53.0

func (s *ServiceRuntime) WaitForDependenciesWithConnectionDetails(mainResource string, objectCDMap map[string][]string) (bool, error)

WaitForDependenciesWithConnectionDetails does the same as WaitForDependencies but additionally also checks the given list of fields against the available connection details. objectCDMap should contain a map where the key is the name of the dependeny and the string slice the necessary connection detail fields.

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