config

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 30 Imported by: 4

Documentation

Index

Constants

View Source
const SaveExpandedWriterKey = "expanded-writer"

SaveExpandedWriterKey define the key name for saving the expanded writer config

View Source
const SaveInputPropertiesKey = "input-properties"

SaveInputPropertiesKey define the key name for saving the input properties in the secret.

View Source
const SaveObjectReferenceKey = "objects-reference"

SaveObjectReferenceKey define the key name for saving the outputs objects reference metadata in the secret.

View Source
const SaveSchemaKey = "schema"

SaveSchemaKey define the key name for saving the API schema

View Source
const SaveTemplateKey = "template"

SaveTemplateKey define the key name for saving the config-template

View Source
const TemplateConfigMapNamePrefix = "config-template-"

TemplateConfigMapNamePrefix the prefix of the configmap name.

Variables

View Source
var ErrChangeSecretType = errors.New("the secret type of the config can not be change")

ErrChangeSecretType means the secret type of the config can not be change

View Source
var ErrChangeTemplate = errors.New("the template of the config can not be change")

ErrChangeTemplate means the template of the config can not be change

View Source
var ErrConfigExist = errors.New("the config is exist")

ErrConfigExist means the config is exist.

View Source
var ErrConfigNotFound = errors.New("the config is not exist")

ErrConfigNotFound means the config is not exist

View Source
var ErrNoConfigOrTarget = errors.New("you must specify the config name and destination to distribute")

ErrNoConfigOrTarget means the config or the target is empty.

View Source
var ErrNotFoundDistribution = errors.New("the distribution is not found")

ErrNotFoundDistribution means the app of the distribution is not exist.

View Source
var ErrSensitiveConfig = errors.New("the config is sensitive")

ErrSensitiveConfig means this config can not be read directly.

View Source
var ErrTemplateNotFound = errors.New("the template is not exist")

ErrTemplateNotFound means the template is not exist

Functions

func DefaultDistributionName

func DefaultDistributionName(configName string) string

DefaultDistributionName generate the distribution name by a config name

func IsFieldNotExist

func IsFieldNotExist(err error) bool

IsFieldNotExist check whether the error type is the field not found

Types

type ClusterTarget

type ClusterTarget struct {
	ClusterName string `json:"clusterName"`
	Namespace   string `json:"namespace"`
}

ClusterTarget kubernetes delivery target

type ClusterTargetStatus

type ClusterTargetStatus struct {
	ClusterTarget
	Status      string         `json:"status"`
	Application NamespacedName `json:"application"`
	Message     string         `json:"message"`
}

ClusterTargetStatus merge the status of the distribution

type Config

type Config struct {
	Metadata
	CreateTime time.Time
	Template   Template `json:"template"`
	// Secret this is default output way.
	Secret *v1.Secret `json:"secret"`

	// ExpandedWriterData
	ExpandedWriterData *writer.ExpandedWriterData `json:"expandedWriterData"`

	// OutputObjects this means users could define other objects.
	// This field assign value only on config render stage.
	OutputObjects map[string]*unstructured.Unstructured

	// ObjectReferences correspond OutputObjects
	ObjectReferences []v1.ObjectReference

	Targets []*ClusterTargetStatus
}

Config this is the config model, generated from the template and properties.

type CreateDistributionSpec

type CreateDistributionSpec struct {
	Configs []*NamespacedName
	Targets []*ClusterTarget
}

CreateDistributionSpec the spec of the distribution

type Dispatcher added in v1.7.1

Dispatcher is a client for apply resources.

type Distribution

type Distribution struct {
	Name        string                  `json:"name"`
	Namespace   string                  `json:"namespace"`
	CreatedTime time.Time               `json:"createdTime"`
	Configs     []*NamespacedName       `json:"configs"`
	Targets     []*ClusterTarget        `json:"targets"`
	Application pkgtypes.NamespacedName `json:"application"`
	Status      common.AppStatus        `json:"status"`
}

Distribution the config distribution model

type Factory

type Factory interface {
	ParseTemplate(defaultName string, content []byte) (*Template, error)
	ParseConfig(ctx context.Context, template NamespacedName, meta Metadata) (*Config, error)

	LoadTemplate(ctx context.Context, name, ns string) (*Template, error)
	CreateOrUpdateConfigTemplate(ctx context.Context, ns string, it *Template) error
	DeleteTemplate(ctx context.Context, ns, name string) error
	ListTemplates(ctx context.Context, ns, scope string) ([]*Template, error)

	ReadConfig(ctx context.Context, namespace, name string) (map[string]interface{}, error)
	GetConfig(ctx context.Context, namespace, name string, withStatus bool) (*Config, error)
	ListConfigs(ctx context.Context, namespace, template, scope string, withStatus bool) ([]*Config, error)
	DeleteConfig(ctx context.Context, namespace, name string) error
	CreateOrUpdateConfig(ctx context.Context, i *Config, ns string) error
	IsExist(ctx context.Context, namespace, name string) (bool, error)

	CreateOrUpdateDistribution(ctx context.Context, ns, name string, ads *CreateDistributionSpec) error
	ListDistributions(ctx context.Context, ns string) ([]*Distribution, error)
	DeleteDistribution(ctx context.Context, ns, name string) error
	MergeDistributionStatus(ctx context.Context, config *Config, namespace string) error
}

Factory handle the config

func NewConfigFactory

func NewConfigFactory(cli client.Client) Factory

NewConfigFactory create a config factory instance

func NewConfigFactoryWithDispatcher added in v1.7.1

func NewConfigFactoryWithDispatcher(cli client.Client, ds Dispatcher) Factory

NewConfigFactoryWithDispatcher create a config factory instance with a specified dispatcher

type Metadata

type Metadata struct {
	NamespacedName
	Alias       string                 `json:"alias,omitempty"`
	Description string                 `json:"description,omitempty"`
	Properties  map[string]interface{} `json:"properties"`
}

Metadata users should provide this model.

type NamespacedName

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

NamespacedName the namespace and name model

type Template

type Template struct {
	NamespacedName
	Alias       string `json:"alias,omitempty"`
	Description string `json:"description,omitempty"`
	// Scope defines the usage scope of the configuration template. Provides two options: System or Namespace
	// System: The system users could use this template, and the config secret will save in the vela-system namespace.
	// Namespace: The config secret will save in the target namespace, such as this namespace belonging to one project.
	Scope string `json:"scope"`
	// Sensitive means this config config can not be read from the API or the workflow step, only support the safe way, such as Secret.
	Sensitive bool `json:"sensitive"`

	CreateTime time.Time `json:"createTime"`

	Template script.CUE `json:"template"`

	ExpandedWriter writer.ExpandedWriterConfig `json:"expandedWriter"`

	Schema *openapi3.Schema `json:"schema"`

	ConfigMap *v1.ConfigMap `json:"-"`
}

Template This is the spec of the config template, parse from the cue script.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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