Documentation
¶
Index ¶
- Constants
- func AddResourcesTo(o any, opts *AddResourcesOptions) error
- func DataResourcesFromYaml(in []byte) (result []unstructured.Unstructured, err error)
- func GetResourceName(cd *resource.DesiredComposed) string
- func JsonByteToRawExtension(jsonByte []byte) (runtime.RawExtension, error)
- func JsonByteToUnstructured(jsonByte []byte) (*unstructured.Unstructured, error)
- func MergeContext(req *fnv1.RunFunctionRequest, val map[string]interface{}) (map[string]interface{}, error)
- func ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
- func SetConditions(rsp *fnv1.RunFunctionResponse, cr ConditionResources, log logging.Logger) error
- func SetData(data any, path string, o any, overwrite bool) error
- func SetEvents(rsp *fnv1.RunFunctionResponse, ers EventResources) error
- func UnstructuredToRawExtension(obj *unstructured.Unstructured) (runtime.RawExtension, error)
- type AddResourcesOptions
- type AddResourcesResult
- type BindingTarget
- type Condition
- type ConditionResource
- type ConditionResources
- type CreateEvent
- type DesiredMatch
- type Event
- type EventResources
- type EventType
- type ExtraResourcesRequirement
- type ExtraResourcesRequirements
- type Resource
- type ResourceList
- type Target
Constants ¶
const ( AnnotationKeyReady = "krm.kcl.dev/ready" AnnotationKeyCompositionResourceName = "krm.kcl.dev/composition-resource-name" MetaApiVersion = "meta.krm.kcl.dev/v1alpha1" )
Variables ¶
This section is empty.
Functions ¶
func AddResourcesTo ¶
func AddResourcesTo(o any, opts *AddResourcesOptions) error
AddResourcesTo adds the given data to any allowed object passed Will return err if the object is not of a supported type For 'desired' composed resources, the Basename is used for the resource name For 'xr' resources, the Basename must match the xr name For 'existing' resources, the Basename must match the resource name
func DataResourcesFromYaml ¶
func DataResourcesFromYaml(in []byte) (result []unstructured.Unstructured, err error)
DataResourcesFromYaml returns the manifests list from the YAML stream data.
func GetResourceName ¶ added in v0.9.2
func GetResourceName(cd *resource.DesiredComposed) string
func JsonByteToRawExtension ¶ added in v0.5.0
func JsonByteToRawExtension(jsonByte []byte) (runtime.RawExtension, error)
func JsonByteToUnstructured ¶
func JsonByteToUnstructured(jsonByte []byte) (*unstructured.Unstructured, error)
func MergeContext ¶ added in v0.11.1
func MergeContext(req *fnv1.RunFunctionRequest, val map[string]interface{}) (map[string]interface{}, error)
MergeContext merges existing Context with new values provided
func ObjToRawExtension ¶
func ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
func SetConditions ¶ added in v0.11.1
func SetConditions(rsp *fnv1.RunFunctionResponse, cr ConditionResources, log logging.Logger) error
SetConditions updates the RunFunctionResponse with specified conditions from ConditionResources, ensuring no duplicates. It validates that system-reserved Crossplane condition types are not set and permits forced updates when specified.
func SetData ¶
SetData is a recursive function that is intended to build a kube fieldpath valid JSONPath(s) of the given object, it will then copy from 'data' at the given path to the passed o object - at the same path, overwrite defines if this function should be allowed to overwrite values or not, if not return an conflicting value error
If the resource to write to 'o' contains a nil .Resource, setData will return an error It is expected that the resource is created via composed.New() or composite.New() prior to calling setData
func SetEvents ¶ added in v0.11.1
func SetEvents(rsp *fnv1.RunFunctionResponse, ers EventResources) error
SetEvents processes a list of EventResources, transforms them into Results, and appends them to the RunFunctionResponse. Returns an error if any transformation fails.
func UnstructuredToRawExtension ¶
func UnstructuredToRawExtension(obj *unstructured.Unstructured) (runtime.RawExtension, error)
Types ¶
type AddResourcesOptions ¶
type AddResourcesOptions struct {
Basename string
Data []unstructured.Unstructured
Overwrite bool
}
type AddResourcesResult ¶
func ProcessResources ¶
func ProcessResources(dxr *resource.Composite, oxr *resource.Composite, desired map[resource.Name]*resource.DesiredComposed, observed map[resource.Name]resource.ObservedComposed, extraResources map[string]*fnv1.ResourceSelector, conditions *ConditionResources, events *EventResources, contextData *map[string]interface{}, target Target, resources ResourceList, opts *AddResourcesOptions) (AddResourcesResult, error)
type BindingTarget ¶ added in v0.11.1
type BindingTarget string
Target determines which objects to set the condition on.
const ( // TargetComposite targets only the composite resource. TargetComposite BindingTarget = "Composite" // TargetCompositeAndClaim targets both the composite and the claim. TargetCompositeAndClaim BindingTarget = "CompositeAndClaim" )
type Condition ¶ added in v0.11.1
type Condition struct {
// Type of the condition. Required.
Type string `json:"type"`
// Status of the condition. Required.
Status metav1.ConditionStatus `json:"status"`
// Reason of the condition. Required.
Reason string `json:"reason"`
// Message of the condition. Optional. A template can be used. The available
// template variables come from capturing groups in MatchCondition message
// regular expressions.
Message *string `json:"message"`
}
Condition allows you to specify fields to set on a composite resource and claim.
type ConditionResource ¶ added in v0.11.1
type ConditionResource struct {
// The target(s) to receive the condition. Can be Composite or
// CompositeAndClaim. Defaults to Composite
Target *BindingTarget `json:"target"`
// If true, the condition will override a condition of the same Type. Defaults
// to false.
Force *bool `json:"force"`
// Condition to set.
Condition Condition `json:"condition"`
}
ConditionResource will set a condition on the target.
type ConditionResources ¶ added in v0.11.1
type ConditionResources []ConditionResource
type CreateEvent ¶ added in v0.11.1
type CreateEvent struct {
// The target(s) to create an event for. Can be Composite or
// CompositeAndClaim. Defaults to Composite
Target *BindingTarget `json:"target"`
// Event to create.
Event Event `json:"event"`
}
CreateEvent will create an event for the target(s).
type DesiredMatch ¶
type DesiredMatch map[*resource.DesiredComposed][]map[string]interface{}
DesiredMatch matches a list of data to apply to a desired resource This is used when targeting PatchDesired resources
func MatchResources ¶
func MatchResources(desired map[resource.Name]*resource.DesiredComposed, data []unstructured.Unstructured) (DesiredMatch, error)
MatchResources finds and associates the data to the desired resource The length of the passed data should match the total count of desired match data
type Event ¶ added in v0.11.1
type Event struct {
// Type of the event. Optional. Should be either Normal or Warning.
Type *EventType `json:"type"`
// Reason of the event. Optional.
Reason *string `json:"reason"`
// Message of the event. Required. A template can be used. The available
// template variables come from capturing groups in MatchCondition message
// regular expressions.
Message string `json:"message"`
}
Event allows you to specify the fields of an event to create.
type EventResources ¶ added in v0.11.1
type EventResources []CreateEvent
type ExtraResourcesRequirement ¶ added in v0.10.1
type ExtraResourcesRequirement struct {
// APIVersion of the resource.
APIVersion string `json:"apiVersion"`
// Kind of the resource.
Kind string `json:"kind"`
// MatchLabels defines the labels to match the resource, if defined,
// matchName is ignored.
MatchLabels map[string]string `json:"matchLabels,omitempty"`
// MatchName defines the name to match the resource, if MatchLabels is
// empty.
MatchName string `json:"matchName,omitempty"`
// MatchNamespace defines the namespace to match a namespace scoped resource, if set.
// Otherwise the resource is assumed to be cluster scoped.
MatchNamespace string `json:"matchNamespace,omitempty"`
}
ExtraResourcesRequirement defines a single requirement for extra resources. Needed to have camelCase keys instead of the snake_case keys as defined through json tags by fnv1.ResourceSelector.
func (*ExtraResourcesRequirement) ToResourceSelector ¶ added in v0.10.1
func (e *ExtraResourcesRequirement) ToResourceSelector() *fnv1.ResourceSelector
ToResourceSelector converts the ExtraResourcesRequirement to a fnv1.ResourceSelector.
type ExtraResourcesRequirements ¶ added in v0.10.1
type ExtraResourcesRequirements map[string]ExtraResourcesRequirement
ExtraResourcesRequirements defines the requirements for extra resources.
type Resource ¶
type Resource struct {
// Name is a unique identifier for this entry in a ResourceList
Name string `json:"name"`
Base unstructured.Unstructured `json:"base,omitempty"`
}
type ResourceList ¶
type ResourceList []Resource
type Target ¶
type Target string
const ( // PatchDesired targets existing Resources on the Desired XR PatchDesired Target = "PatchDesired" // PatchResources targets existing KCLInput.spec.Resources // These resources are then created similar to the Resources target PatchResources Target = "PatchResources" // Resources creates new resources that are added to the DesiredComposed Resources Resources Target = "Resources" // XR targets the existing Observed XR itself XR Target = "XR" // Default targets the existing all resources including XR, Desired XR, // spec.Resources and DesiredComposed Resources. Default Target = "Default" )