Documentation ¶
Overview ¶
Package definition contains some helper functions used in vela CLI and vela addon mechanism
Index ¶
- Constants
- Variables
- func GetDefinitionDefaultSpec(kind string) map[string]interface{}
- func SearchDefinition(definitionName string, c client.Client, definitionType string, ...) ([]unstructured.Unstructured, error)
- func ValidDefinitionTypes() []string
- type Definition
- func (def *Definition) FromCUE(val *cue.Value, templateString string) error
- func (def *Definition) FromCUEString(cueString string, config *rest.Config) error
- func (def *Definition) GetType() string
- func (def *Definition) SetGVK(kind string)
- func (def *Definition) SetType(t string) error
- func (def *Definition) ToCUE() (*cue.Value, string, error)
- func (def *Definition) ToCUEString() (string, error)
Constants ¶
const ( // DescriptionKey the key for accessing definition description DescriptionKey = "definition.oam.dev/description" // UserPrefix defines the prefix of user customized label or annotation UserPrefix = "custom.definition.oam.dev/" )
Variables ¶
var ( // DefinitionTemplateKeys the keys for accessing definition template DefinitionTemplateKeys = []string{"spec", "schematic", "cue", "template"} // DefinitionTypeToKind maps the definition types to corresponding kinds DefinitionTypeToKind = map[string]string{ "component": v1beta1.ComponentDefinitionKind, "trait": v1beta1.TraitDefinitionKind, "policy": v1beta1.PolicyDefinitionKind, "workload": v1beta1.WorkloadDefinitionKind, "scope": v1beta1.ScopeDefinitionKind, "workflow-step": v1beta1.WorkflowStepDefinitionKind, } )
Functions ¶
func GetDefinitionDefaultSpec ¶
GetDefinitionDefaultSpec returns the default spec of Definition with given kind. This may be implemented with cue in the future.
func SearchDefinition ¶
func SearchDefinition(definitionName string, c client.Client, definitionType string, namespace string) ([]unstructured.Unstructured, error)
SearchDefinition search the Definition in k8s by traversing all possible results across types or namespaces
func ValidDefinitionTypes ¶
func ValidDefinitionTypes() []string
ValidDefinitionTypes return the list of valid definition types
Types ¶
type Definition ¶
type Definition struct {
unstructured.Unstructured
}
Definition the general struct for handling all kinds of definitions like ComponentDefinition or TraitDefinition
func (*Definition) FromCUE ¶
func (def *Definition) FromCUE(val *cue.Value, templateString string) error
FromCUE converts CUE value (predefined Definition's cue format) to Definition nolint:gocyclo
func (*Definition) FromCUEString ¶
func (def *Definition) FromCUEString(cueString string, config *rest.Config) error
FromCUEString converts cue string into Definition
func (*Definition) GetType ¶
func (def *Definition) GetType() string
GetType gets the type of Definition
func (*Definition) SetGVK ¶
func (def *Definition) SetGVK(kind string)
SetGVK set the GroupVersionKind of Definition
func (*Definition) SetType ¶
func (def *Definition) SetType(t string) error
SetType sets the type of Definition
func (*Definition) ToCUE ¶
func (def *Definition) ToCUE() (*cue.Value, string, error)
ToCUE converts Definition to CUE value (with predefined Definition's cue format)
func (*Definition) ToCUEString ¶
func (def *Definition) ToCUEString() (string, error)
ToCUEString converts definition to CUE value and then encode to string