resource

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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 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

func SetData(data any, path string, o any, overwrite bool) error

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

type AddResourcesResult struct {
	Target   Target
	Object   any
	MsgCount int
	Msgs     []string
}

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 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"
)

Jump to

Keyboard shortcuts

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