Documentation
¶
Index ¶
- Constants
- Variables
- type Factory
- type Item
- type K8sFactory
- func (f *K8sFactory) CreateOrUpdateConfig(ctx context.Context, configItem any, ns string) error
- func (f *K8sFactory) DeleteConfig(ctx context.Context, namespace, name string) error
- func (f *K8sFactory) ListConfigs(ctx context.Context, namespace, template, _ string, _ bool) ([]*Item, error)
- func (f *K8sFactory) ParseConfig(ctx context.Context, template NamespacedName, meta Metadata) (any, error)
- func (f *K8sFactory) ReadConfig(ctx context.Context, namespace, name string) (map[string]interface{}, error)
- type Metadata
- type NamespacedName
Constants ¶
const ( // LabelConfigCatalog identifies a Secret as a workflow config. LabelConfigCatalog = "config.oam.dev/catalog" // LabelConfigType stores the template name that generated this config. LabelConfigType = "config.oam.dev/type" // LabelConfigScope stores the scope of the config. LabelConfigScope = "config.oam.dev/scope" // CatalogValue is the value for the catalog label. CatalogValue = "velacore-config" // DataKeyProperties is the Secret data key for config properties. DataKeyProperties = "input-properties" // DataKeyObjectReference is the Secret data key for output object references. DataKeyObjectReference = "objects-reference" // DataKeyTemplate is the ConfigMap data key for the CUE template script. DataKeyTemplate = "template" // AnnotationConfigSensitive marks a config as sensitive (not readable via API). AnnotationConfigSensitive = "config.oam.dev/sensitive" // AnnotationConfigAlias stores the alias of a config. AnnotationConfigAlias = "config.oam.dev/alias" // AnnotationConfigDescription stores the description of a config. AnnotationConfigDescription = "config.oam.dev/description" // AnnotationConfigTemplateNamespace stores the namespace of the template that generated this config. AnnotationConfigTemplateNamespace = "config.oam.dev/template-namespace" // AnnoLastAppliedConfig is the annotation for 3-way merge last applied config. AnnoLastAppliedConfig = "config.oam.dev/last-applied-configuration" // AnnoLastAppliedTime is the annotation for 3-way merge last applied time. AnnoLastAppliedTime = "config.oam.dev/last-applied-time" // TemplateConfigMapNamePrefix is the prefix of config template ConfigMap names. TemplateConfigMapNamePrefix = "config-template-" // TemplateOutput is the CUE path for the output secret in a config template. TemplateOutput = "template.output" // TemplateOutputs is the CUE path for additional output objects in a config template. TemplateOutputs = "template.outputs" // TemplateValidationReturns is the CUE path for validation returns in a config template. TemplateValidationReturns = "template.validation.$returns" )
Variables ¶
var DefaultContext = []byte(`
context: {
name: string
namespace: string
}
`)
DefaultContext is the default CUE context template appended to config templates.
var ErrChangeSecretType = fmt.Errorf("the secret type of the config can not be changed")
ErrChangeSecretType means the secret type of the config cannot be changed.
var ErrChangeTemplate = fmt.Errorf("the template of the config can not be changed")
ErrChangeTemplate means the template of the config cannot be changed.
var ErrSensitiveConfig = fmt.Errorf("the config is sensitive")
ErrSensitiveConfig means this config cannot be read directly.
var ErrTemplateNotFound = fmt.Errorf("the template does not exist")
ErrTemplateNotFound means the config template does not exist.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface {
ParseConfig(ctx context.Context, template NamespacedName, meta Metadata) (any, error)
CreateOrUpdateConfig(ctx context.Context, configItem any, ns string) error
ReadConfig(ctx context.Context, namespace, name string) (map[string]interface{}, error)
ListConfigs(ctx context.Context, namespace, template, scope string, withStatus bool) ([]*Item, error)
DeleteConfig(ctx context.Context, namespace, name string) error
}
Factory defines the config CRUD operations. Implementations are provided by the consuming application (e.g., KubeVela) and injected via RuntimeParams.
func NewK8sFactory ¶
NewK8sFactory creates a new K8sFactory.
type Item ¶
type Item struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]interface{} `json:"properties"`
}
Item is the minimal view of a config returned by ListConfigs.
type K8sFactory ¶
type K8sFactory struct {
// contains filtered or unexported fields
}
K8sFactory is a Kubernetes-backed Factory that stores configs as Secrets and supports CUE template rendering from ConfigMap-stored templates.
func (*K8sFactory) CreateOrUpdateConfig ¶
CreateOrUpdateConfig applies the rendered config Secret using 3-way merge and applies any additional output objects.
func (*K8sFactory) DeleteConfig ¶
func (f *K8sFactory) DeleteConfig(ctx context.Context, namespace, name string) error
DeleteConfig deletes a config Secret and cleans up any referenced output objects.
func (*K8sFactory) ListConfigs ¶
func (f *K8sFactory) ListConfigs(ctx context.Context, namespace, template, _ string, _ bool) ([]*Item, error)
ListConfigs lists config Secrets filtered by template name.
func (*K8sFactory) ParseConfig ¶
func (f *K8sFactory) ParseConfig(ctx context.Context, template NamespacedName, meta Metadata) (any, error)
ParseConfig loads a config template (if specified), compiles it with the provided properties, and returns a renderedConfig containing the output Secret and any additional output objects.
func (*K8sFactory) ReadConfig ¶
func (f *K8sFactory) ReadConfig(ctx context.Context, namespace, name string) (map[string]interface{}, error)
ReadConfig reads a config Secret and returns its properties.
type Metadata ¶
type Metadata struct {
NamespacedName
Alias string `json:"alias,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]interface{} `json:"properties"`
}
Metadata is the user-provided metadata for a config item.
type NamespacedName ¶
NamespacedName is a namespace/name pair for config references.