runtime

package
v4.111.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OwnerKindAnnotation    = "appcat.vshn.io/ownerkind"
	OwnerVersionAnnotation = "appcat.vshn.io/ownerapiversion"
	OwnerGroupAnnotation   = "appcat.vshn.io/ownergroup"
	ProtectedByAnnotation  = "appcat.vshn.io/protectedby"
	ProtectsAnnotation     = "appcat.vshn.io/protects"
	EventForwardAnnotation = "appcat.vshn.io/forward-events-to"

	ProviderConfigIgnoreLabel = "appcat.vshn.io/ignore-provider-config"
	WebhookAllowDeletionLabel = "appcat.vshn.io/webhook-allowdeletion"
)

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 EscapeDNS1123 added in v4.78.1

func EscapeDNS1123(name string, allowColons bool) string

EscapeDNS1123 will always return a string that conforms to K8s' DNS subdomain naming scheme contain no more than 253 characters contain only lowercase alphanumeric characters, '-' or '.' start with an alphanumeric character end with an alphanumeric character We also remove any '.' here, so that it can be used as a base function for escaping label names as well.

func EscapeDNS1123Label added in v4.78.1

func EscapeDNS1123Label(name string, length int) string

EscapeDNS1123Label does the same as escapeDNS1123 but also limit to 63 chars

func KubeOptionAllowDeletion added in v4.102.0

func KubeOptionAllowDeletion(obj *xkube.Object)

KubeOptionAllowDeletion adds the allow deletion label to the object

func KubeOptionObserve added in v4.103.0

func KubeOptionObserve(obj *xkube.Object)

KubeOptionObserve sets the object to only observe.

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[T client.Object](name string, function Service[T])

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

Types

type ComposedResourceOption added in v4.73.0

type ComposedResourceOption func(obj xpresource.Managed)

ComposedResourceOption defines the type of functional parameters for Crossplane managed resources

func ComposedOptionProtectedBy added in v4.73.0

func ComposedOptionProtectedBy(resName string) ComposedResourceOption

ComposedOptionProtectedBy protects the given resource from deletion as long as resName exists. resName is the name of the resource in the desired map.

func ComposedOptionProtects added in v4.73.0

func ComposedOptionProtects(resName string) ComposedResourceOption

ComposedOptionProtects is the inverse of ProtectedBy. The object with this annotation protects the object with resName.

type KubeObjectOption added in v4.53.0

type KubeObjectOption func(obj *xkube.Object)

KubeObjectOption defines the type of functional parameters for kubeObjects

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 KubeOptionAddLabels added in v4.103.0

func KubeOptionAddLabels(labels map[string]string) KubeObjectOption

KubeOptionLabeler adds the given labels to the kube object.

func KubeOptionAddRefs added in v4.53.0

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

KubeOptionAddRefs adds the given references to the kube object.

func KubeOptionProtectedBy added in v4.73.0

func KubeOptionProtectedBy(resName string) KubeObjectOption

KubeOptionProtectedBy protects the given kube objects from deletion as long as resName exists. resName is the name of the resource in the desired map.

func KubeOptionProtects added in v4.73.0

func KubeOptionProtects(resName string) KubeObjectOption

KubeOptionProtects is the inverse of ProtectedBy. The object with this annotation protects the object with resName.

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[T client.Object] struct {
	Steps []Step[T]
}

Service contains all steps necessary to provide the service (except the legacy P+T portion). We use reflect heavily with this, any changes in the ordering of the fields need to be adjusted in the `RunFunction` function.

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) AddLabels added in v4.105.0

func (s *ServiceRuntime) AddLabels(obj client.Object, labels map[string]string)

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) ForwardEvents added in v4.75.0

func (s *ServiceRuntime) ForwardEvents() error

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, opts ...ComposedResourceOption) 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, opts ...ComposedResourceOption) 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) 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) UsageOfBy added in v4.73.0

func (s *ServiceRuntime) UsageOfBy(of, by string) error

UsageOfBy helps with ordered deletions. Sometimes there are objects that are essential for porviders to work. For example provider-sql needs secrets to connect to instances. During the deletion it's not guaranteed that the secret gets deleted after the managed resource that the provider manages. This will essentially make it deadlock, as the managed resource will still contain a finalizer which blocks the deletion. See: https://docs.crossplane.io/latest/concepts/usages/#usage-for-deletion-ordering

Of is the name of the managed resource that should be protected, as set in the desired map By is the name of then managed resource which should block the deletion, as set in the desired map. As long as it exists the deletion of "Of" will be denied.

func (*ServiceRuntime) WaitForDesiredDependencies added in v4.94.1

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

WaitForDesiredDependencies 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) WaitForObservedDependencies added in v4.94.1

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

WaitForObservedDependencies 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) WaitForObservedDependenciesWithConnectionDetails added in v4.94.1

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

WaitForObservedDependenciesWithConnectionDetails 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[T client.Object] struct {
	Name    string
	Execute func(context.Context, T, *ServiceRuntime) *xfnproto.Result
}

Step describes a single change within a service. It's essentially what was previously called a TransformFunc. We use reflect heavily with this, any changes in the ordering of the fields need to be adjusted in the `RunFunction` function.

Jump to

Keyboard shortcuts

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