config

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

View Source
var DefaultContext = []byte(`
	context: {
		name: string
		namespace: string
	}
`)

DefaultContext is the default CUE context template appended to config templates.

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

View Source
var ErrChangeTemplate = fmt.Errorf("the template of the config can not be changed")

ErrChangeTemplate means the template of the config cannot be changed.

View Source
var ErrSensitiveConfig = fmt.Errorf("the config is sensitive")

ErrSensitiveConfig means this config cannot be read directly.

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

func NewK8sFactory(cli client.Client) Factory

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

func (f *K8sFactory) CreateOrUpdateConfig(ctx context.Context, configItem any, ns string) error

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

type NamespacedName struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

NamespacedName is a namespace/name pair for config references.

Jump to

Keyboard shortcuts

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