Documentation
¶
Index ¶
- Constants
- func AddResourcesTo(o any, opts *AddResourcesOptions) error
- func CheckAndSetDesired(desired map[resource.Name]*resource.DesiredComposed, ...) 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 ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
- func SetData(data any, path string, o any, overwrite bool) error
- func UnstructuredToRawExtension(obj *unstructured.Unstructured) (runtime.RawExtension, error)
- type AddResourcesOptions
- type AddResourcesResult
- type DesiredMatch
- 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 CheckAndSetDesired ¶ added in v0.9.2
func CheckAndSetDesired(desired map[resource.Name]*resource.DesiredComposed, checked map[string]struct{}, cd *resource.DesiredComposed) error
Check the set the resource into the desired resource map.
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 ObjToRawExtension ¶
func ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
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 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, target Target, resources ResourceList, opts *AddResourcesOptions) (AddResourcesResult, error)
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 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"`
}
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" )