Documentation
¶
Index ¶
- Constants
- Variables
- func AllowConfigAccess(ctx context.Context, cli client.Client, ...) error
- func AllowStepConfigAccess(ctx context.Context, cli client.Client, appLabels map[string]string, ...) error
- func DefaultDistributionName(configName string) string
- func IsFieldNotExist(err error) bool
- func SharedSystemConfig(ctx context.Context, cli client.Client, name string) (bool, error)
- func StepListScope(ctx context.Context, cli client.Client, appLabels map[string]string, ...) (string, error)
- func StepReadContext(ctx context.Context, appLabels map[string]string, namespace string) context.Context
- type ClusterTarget
- type ClusterTargetStatus
- type Config
- type ConfigAccess
- type CreateDistributionSpec
- type Dispatcher
- type Distribution
- type Factory
- type Metadata
- type NamespacedName
- type Template
- type TemplateMetadata
- type Validation
Constants ¶
const SaveExpandedWriterKey = "expanded-writer"
SaveExpandedWriterKey define the key name for saving the expanded writer config
const SaveInputPropertiesKey = "input-properties"
SaveInputPropertiesKey define the key name for saving the input properties in the secret.
const SaveObjectReferenceKey = "objects-reference"
SaveObjectReferenceKey define the key name for saving the outputs objects reference metadata in the secret.
const SaveSchemaKey = "schema"
SaveSchemaKey define the key name for saving the API schema
const SaveTemplateKey = "template"
SaveTemplateKey define the key name for saving the config-template
const ScopeSystem = "system"
ScopeSystem is the scope of a template whose configs live in the system namespace and are shared with every namespace.
const TemplateConfigMapNamePrefix = "config-template-"
TemplateConfigMapNamePrefix the prefix of the configmap name.
const TemplateOutput = SaveTemplateKey + ".output"
TemplateOutput define the key name for the config-template output
const TemplateOutputs = SaveTemplateKey + ".outputs"
TemplateOutputs define the key name for the config-template outputs
const TemplateValidationReturns = SaveTemplateKey + ".validation.$returns"
TemplateValidationReturns define the key name for the config-template validation returns
Variables ¶
var ErrChangeSecretType = errors.New("the secret type of the config can not be changed")
ErrChangeSecretType means the secret type of the config can not be changed
var ErrChangeTemplate = errors.New("the template of the config can not be changed")
ErrChangeTemplate means the template of the config can not be changed
var ErrConfigExist = errors.New("the config does exist")
ErrConfigExist means the config does exist.
var ErrConfigNotFound = errors.New("the config does not exist")
ErrConfigNotFound means the config does not exist
var ErrNoConfigOrTarget = errors.New("you must specify the config name and destination to distribute")
ErrNoConfigOrTarget means the config or the target is empty.
var ErrNotFoundDistribution = errors.New("the distribution does not found")
ErrNotFoundDistribution means the app of the distribution does not exist.
var ErrSensitiveConfig = errors.New("the config is sensitive")
ErrSensitiveConfig means this config can not be read directly.
var ErrTemplateNotFound = errors.New("the template does not exist")
ErrTemplateNotFound means the template does not exist
Functions ¶
func AllowConfigAccess ¶ added in v1.10.10
func AllowConfigAccess(ctx context.Context, cli client.Client, verb, namespace, name, template, fromNamespace string) error
AllowConfigAccess applies AccessToConfig for a workflow step acting, as the controller, on configs in namespace for an Application in fromNamespace: allowed in that namespace, for a read of shared system configs, or with a named user in ctx (the AuthenticateApplication gate on) when that user may do the same there. name is empty for a list, which names the template whose configs it reads.
func AllowStepConfigAccess ¶ added in v1.10.10
func AllowStepConfigAccess(ctx context.Context, cli client.Client, appLabels map[string]string, verb, namespace, name, template string) error
AllowStepConfigAccess applies AllowConfigAccess for a workflow step or a policy template, which run in the controller for the Application appLabels name. A write creates the config or overwrites it, so one outside that namespace needs both verbs. A caller with no Application namespace label runs outside the controller, the CLI or a velaql view, with its own client, and is not limited here.
func DefaultDistributionName ¶
DefaultDistributionName generate the distribution name by a config name
func IsFieldNotExist ¶
IsFieldNotExist check whether the error type is the field not found
func SharedSystemConfig ¶ added in v1.10.10
SharedSystemConfig reports whether the config name in the system namespace was made from a system-scoped template, as platform configs are, which makes it readable from any namespace. Only a KubeVela config counts: another Secret there with the scope label is not one.
func StepListScope ¶ added in v1.10.10
func StepListScope(ctx context.Context, cli client.Client, appLabels map[string]string, namespace, template string) (string, error)
StepListScope is the scope a step's list is narrowed to: a list of shared system configs, from another namespace, returns only system-scoped ones, as a read of one of them requires.
func StepReadContext ¶ added in v1.10.10
func StepReadContext(ctx context.Context, appLabels map[string]string, namespace string) context.Context
StepReadContext is what a read AllowStepConfigAccess allowed is made with: outside the Application's namespace, the controller's own identity, since access was already decided (a shared system config, or a user reviewed for it) and the user need not hold the read themselves.
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 ConfigAccess ¶ added in v1.10.10
type ConfigAccess struct {
Review *authorizationv1.ResourceAttributes
Reason string
}
ConfigAccess is the answer to "may an Application in one namespace act on configs in another". A nil Review is yes without a user: the same namespace, or a read of a shared system config. Otherwise the answer is the Application's user's, through Review, with Reason as the denial. Workflow steps run as the controller, so with no user to ask a review is a refusal.
func AccessToConfig ¶ added in v1.10.10
func AccessToConfig(verb, namespace, name, fromNamespace string, sharedSystemConfig bool) ConfigAccess
AccessToConfig answers for verb (get, list, create or delete) on the config name in namespace, from an Application in fromNamespace. sharedSystemConfig says the configs read are shared system configs (SharedSystemConfig), which any namespace may read but not write. A config is a Secret, so the review is of Secrets.
type CreateDistributionSpec ¶
type CreateDistributionSpec struct {
Configs []*NamespacedName `json:"configs"`
Targets []*ClusterTarget `json:"targets"`
}
CreateDistributionSpec the spec of the distribution
type Dispatcher ¶ added in v1.7.1
type Dispatcher func(context.Context, []*unstructured.Unstructured, []apply.ApplyOption) error
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(ctx context.Context, 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 ¶
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 ¶
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 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.
type TemplateMetadata ¶ added in v1.9.0
type TemplateMetadata struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Description string `json:"description,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
Scope string `json:"scope,omitempty"`
}
TemplateMetadata This is the metadata of the config template
type Validation ¶ added in v1.9.0
Validation the response of the validation
func (*Validation) Error ¶ added in v1.9.0
func (e *Validation) Error() string
Error return the error message