Documentation
¶
Overview ¶
Package oam contains miscellaneous OAM helper types.
Index ¶
- Constants
- Variables
- func FilterInternalMetadata(metadata map[string]string) map[string]string
- func GetCluster(o client.Object) string
- func GetControllerRequirement(o client.Object) string
- func GetDeployVersion(o client.Object) string
- func GetLastAppliedTime(o client.Object) time.Time
- func GetPublishVersion(o client.Object) string
- func IsSkipLastAppliedConfig(value string) bool
- func SetCluster(o client.Object, clusterName string)
- func SetClusterIfEmpty(o client.Object, clusterName string)
- func SetControllerRequirement(o client.Object, controllerRequirement string)
- func SetPublishVersion(o client.Object, publishVersion string)
- func ValidatePlacement(value string) error
- type Conditioned
- type Finalizer
- type Object
- type Trait
- type TraitKind
- type Workload
- type WorkloadKind
- type WorkloadReferencer
- type WorkloadsReferencer
Constants ¶
const ( // LabelAppName records the name of AppConfig LabelAppName = "app.oam.dev/name" // LabelAppRevision records the name of Application, it's equal to name of AppConfig created by Application LabelAppRevision = "app.oam.dev/appRevision" // LabelAppComponent records the name of Component LabelAppComponent = "app.oam.dev/component" // LabelReplicaKey records the replica key of Component LabelReplicaKey = "app.oam.dev/replicaKey" // LabelAppComponentRevision records the revision name of Component LabelAppComponentRevision = "app.oam.dev/revision" // LabelOAMResourceType whether a CR is workload or trait LabelOAMResourceType = "app.oam.dev/resourceType" // LabelAppRevisionHash records the Hash value of the application revision LabelAppRevisionHash = "app.oam.dev/app-revision-hash" // LabelAppNamespace records the namespace of Application LabelAppNamespace = "app.oam.dev/namespace" // LabelAppCluster records the cluster of Application LabelAppCluster = "app.oam.dev/cluster" // LabelAppUID records the uid of Application LabelAppUID = "app.oam.dev/uid" // LabelOwnerKind records the kind of a non-Application owner (e.g. Component) of a // ResourceTracker or of a resource it dispatched LabelOwnerKind = "owner.oam.dev/kind" // LabelOwnerName records the name of a non-Application owner LabelOwnerName = "owner.oam.dev/name" // LabelOwnerNamespace records the namespace of a non-Application owner LabelOwnerNamespace = "owner.oam.dev/namespace" // LabelOwnerUID records the uid of a non-Application owner LabelOwnerUID = "owner.oam.dev/uid" // WorkloadTypeLabel indicates the type of the workloadDefinition WorkloadTypeLabel = "workload.oam.dev/type" // TraitTypeLabel indicates the type of the traitDefinition TraitTypeLabel = "trait.oam.dev/type" // TraitResource indicates which resource it is when a trait is composed by multiple resources in KubeVela TraitResource = "trait.oam.dev/resource" // LabelComponentDefinitionName records the name of ComponentDefinition LabelComponentDefinitionName = "componentdefinition.oam.dev/name" // LabelSourceDefinitionName records the name of SourceDefinition LabelSourceDefinitionName = "sourcedefinition.oam.dev/name" // LabelTraitDefinitionName records the name of TraitDefinition LabelTraitDefinitionName = "trait.oam.dev/name" // LabelManageWorkloadTrait indicates if the trait will manage the lifecycle of the workload LabelManageWorkloadTrait = "trait.oam.dev/manage-workload" // LabelPolicyDefinitionName records the name of PolicyDefinition LabelPolicyDefinitionName = "policydefinition.oam.dev/name" // LabelWorkflowStepDefinitionName records the name of WorkflowStepDefinition LabelWorkflowStepDefinitionName = "workflowstepdefinition.oam.dev/name" // LabelControllerRevisionComponent indicate which component the revision belong to LabelControllerRevisionComponent = "controller.oam.dev/component" // LabelAddonName indicates the name of the corresponding Addon LabelAddonName = "addons.oam.dev/name" // LabelAddonAuxiliaryName indicates the name of the auxiliary resource in addon app template LabelAddonAuxiliaryName = "addons.oam.dev/auxiliary-name" // LabelAddonVersion indicates the version of the corresponding installed Addon LabelAddonVersion = "addons.oam.dev/version" // LabelAddonRegistry indicates the name of addon-registry LabelAddonRegistry = "addons.oam.dev/registry" // LabelNamespaceOfEnvName records the env name of namespace LabelNamespaceOfEnvName = "namespace.oam.dev/env" // LabelNamespaceOfTargetName records the target name of namespace LabelNamespaceOfTargetName = "namespace.oam.dev/target" // LabelControlPlaneNamespaceUsage mark the usage of the namespace in control plane cluster. LabelControlPlaneNamespaceUsage = "usage.oam.dev/control-plane" // LabelRuntimeNamespaceUsage mark the usage of the namespace in runtime cluster. // A control plane cluster can also be used as runtime cluster LabelRuntimeNamespaceUsage = "usage.oam.dev/runtime" // LabelConfigType means the config type LabelConfigType = "config.oam.dev/type" // LabelProject recorde the project the resource belong to LabelProject = "core.oam.dev/project" // LabelResourceRules defines the configmap is representing the resource topology rules LabelResourceRules = "rules.oam.dev/resources" // LabelResourceRuleFormat defines the resource format of the resource topology rules LabelResourceRuleFormat = "rules.oam.dev/resource-format" // LabelControllerName indicates the controller name LabelControllerName = "controller.oam.dev/name" // LabelPreCheck indicates if the target resource is for pre-check test LabelPreCheck = "core.oam.dev/pre-check" )
Label key strings. AppConfig controller will add these labels into workloads.
const ( // VelaNamespaceUsageEnv mark the usage of the namespace is used by env. VelaNamespaceUsageEnv = "env" // VelaNamespaceUsageTarget mark the usage of the namespace is used as delivery target. VelaNamespaceUsageTarget = "target" )
const ( // ResourceTypeTrait mark this K8s Custom Resource is an OAM trait ResourceTypeTrait = "TRAIT" // ResourceTypeWorkload mark this K8s Custom Resource is an OAM workload ResourceTypeWorkload = "WORKLOAD" )
const ( // AnnotationLastAppliedConfig records the previous configuration of a // resource for use in a three-way diff during a patching apply AnnotationLastAppliedConfig = "app.oam.dev/last-applied-configuration" // AnnotationLastAppliedTime indicates the last applied time AnnotationLastAppliedTime = "app.oam.dev/last-applied-time" // AnnotationInplaceUpgrade indicates the workload should upgrade with the the same name // the name of the workload instance should not changing along with the revision AnnotationInplaceUpgrade = "app.oam.dev/inplace-upgrade" // AnnotationAppRevision indicates that the object is an application revision // its controller should not try to reconcile it AnnotationAppRevision = "app.oam.dev/app-revision" // AnnotationKubeVelaVersion is used to record current KubeVela version AnnotationKubeVelaVersion = "oam.dev/kubevela-version" // AnnotationFilterAnnotationKeys is used to filter annotations passed to workload and trait, split by comma AnnotationFilterAnnotationKeys = "filter.oam.dev/annotation-keys" // AnnotationFilterLabelKeys is used to filter labels passed to workload and trait, split by comma AnnotationFilterLabelKeys = "filter.oam.dev/label-keys" // AnnotationDefinitionRevisionName is used to specify the name of DefinitionRevision in component/trait definition AnnotationDefinitionRevisionName = "definitionrevision.oam.dev/name" // AnnotationRestrictNamespaces limits the namespaces whose Applications may use a // definition, as a comma-separated list of namespace names or globs. It is the // channel for definitions whose spec you do not own, such as the builtins helm // installs. A label cannot carry this: label values reject "*" and ",". // // Names only. Restricting by namespace label is spec.restrictions.namespaceSelector // and nothing else, so the annotation stays a flat list with no parsing to get // wrong. AnnotationRestrictNamespaces = "definition.oam.dev/restrict-namespaces" // AnnotationQuotaExempt, set to "true" on a Namespace, lifts every definition // quota for that namespace. It is for getting out of the way of an incident, // not for carving out a permanent exception, so each use is logged. // // Namespaces are cluster scoped, so setting this needs cluster level RBAC. It // lifts quotas only; which definitions a namespace may use at all is not // something a namespace gets to decide about itself. AnnotationQuotaExempt = "definition.oam.dev/quota-exempt" // AnnotationLastAppliedConfiguration is kubectl annotations for 3-way merge AnnotationLastAppliedConfiguration = "kubectl.kubernetes.io/last-applied-configuration" // AnnotationDeployVersion know the version number of the deployment. AnnotationDeployVersion = "app.oam.dev/deployVersion" // AnnotationPublishVersion is annotation that record the application workflow version. AnnotationPublishVersion = "app.oam.dev/publishVersion" // AnnotationAutoUpdate is annotation that let application auto update when it finds definition changes AnnotationAutoUpdate = "app.oam.dev/autoUpdate" // AnnotationCelExpressions opts one Application in to $( ) property // expressions while RequireCelExpressionOptIn is on. Any value other than // "true" leaves the Application as it was. // // Per-Application rather than per-namespace because the thing being opted in // to is a reading of the Application's own property values: a $(VAR) that used // to reach the container verbatim now has to be written $$(VAR). Whoever owns // the Application is who can answer for that. // // Named for the expressions and not for sources: $(context.appName) needs no // SourceDefinition, and what an Application opts in to here is having its // properties read for $( ) at all. Sources are the first thing expressions // made worth having, not the boundary of what they will be used for. AnnotationCelExpressions = "app.oam.dev/cel-expressions" // AnnotationAutoRevision controls whether policy-rendered spec changes create new ApplicationRevisions. // When set to "true", policies can modify Application.Spec and trigger new revisions. // This is orthogonal to AnnotationAutoUpdate which controls definition version updates. // Like the other policy rollout annotations it takes "true", "false" or a comma-separated // list of PolicyDefinition names; without it the controller default applies. AnnotationAutoRevision = "policy.oam.dev/auto-revision" // AnnotationApplyPolicyUpdates controls whether an Application adopts new versions of the // Application-scoped policies it runs ("true", "false" or a list of PolicyDefinition names). AnnotationApplyPolicyUpdates = "policy.oam.dev/apply-policy-updates" // AnnotationApplyDataChanges controls whether an Application takes changed output from an // unchanged policy version, such as values the policy reads from the cluster ("true", // "false" or a list of PolicyDefinition names). AnnotationApplyDataChanges = "policy.oam.dev/apply-data-changes" // AnnotationPolicyContextHash records, on an Application's current ResourceTracker, a hash of // each policy instance's context output when its components were last applied: a // JSON map from policy instance (global:<name>, or the spec.policies name) to hash. A change for // a policy with apply-data-changes on re-applies the components without a new revision. AnnotationPolicyContextHash = "app.oam.dev/policy-context-hash" // AnnotationAppGeneration records, on an ApplicationRevision, the generation of the Application // it was last written for. A revision stores the spec after policy transforms, so this tells an // author edit apart from a spec-rewriting policy. AnnotationAppGeneration = "app.oam.dev/application-generation" // AnnotationSourceResolvedHash records per-source hashes of the source // values a component consumed at dispatch time (JSON map of source name -> // hash). It is stamped on the dispatched workload so a later reconcile can // detect that a source re-resolved to a different value (which the raw spec // comparison cannot see) and re-dispatch. AnnotationSourceResolvedHash = "source.oam.dev/resolved-hash" // AnnotationSkipGlobalPolicies controls whether global (vela-system) policies are skipped for an Application. // When set to "true", only explicitly declared spec.policies are evaluated. AnnotationSkipGlobalPolicies = "policy.oam.dev/skip-global" // AnnotationForceParamMutations bypasses all immutable parameter field validation when set to "true". AnnotationForceParamMutations = "app.oam.dev/force-param-mutations" // AnnotationWorkflowName specifies the workflow name for execution. AnnotationWorkflowName = "app.oam.dev/workflowName" // AnnotationWorkflowRestart triggers a workflow restart when set. Supported values: // - "true": Immediate restart (sets restart time to current time + 1 second). // Annotation is automatically removed after being processed. // - RFC3339 timestamp (e.g., "2025-01-15T14:30:00Z"): One-time restart at specified time. // Annotation is automatically removed after being processed. // - Duration (e.g., "5m", "1h", "30s"): Recurring restart with minimum interval after each completion. // Annotation persists; automatically reschedules after each workflow completion. // All modes are GitOps-safe: the schedule is stored in status.workflowRestartScheduledAt. AnnotationWorkflowRestart = "app.oam.dev/restart-workflow" // AnnotationAppName specifies the name for application in db. // Note: the annotation is only created by velaUX, please don't use it in other Source of Truth. AnnotationAppName = "app.oam.dev/appName" // AnnotationAppAlias specifies the alias for application in db. AnnotationAppAlias = "app.oam.dev/appAlias" // AnnotationControllerRequirement indicates the controller version that can process the application/definition. AnnotationControllerRequirement = "app.oam.dev/controller-version-require" // AnnotationApplicationServiceAccountName indicates the name of the ServiceAccount to use to apply Components and run Workflow. // ServiceAccount will be used in the local cluster only. AnnotationApplicationServiceAccountName = "app.oam.dev/service-account-name" // AnnotationApplicationUsername indicates the username of the Application to use to apply resources AnnotationApplicationUsername = "app.oam.dev/username" // AnnotationApplicationGroup indicates the group of the Application to use to apply resources AnnotationApplicationGroup = "app.oam.dev/group" AnnotationAppSharedBy = "app.oam.dev/shared-by" // AnnotationResourceURL records the source url of the Kubernetes object AnnotationResourceURL = "app.oam.dev/resource-url" // AnnotationIgnoreWithoutCompKey indicates the bond component. // Deprecated: please use AnnotationAddonDefinitionBindCompKey. AnnotationIgnoreWithoutCompKey = "addon.oam.dev/ignore-without-component" // AnnotationAddonDefinitionBondCompKey indicates the definition in addon bond component. AnnotationAddonDefinitionBondCompKey = "addon.oam.dev/bind-component" // AnnotationModuleInstallNamespace is set by the addon renderer on an owned // addon Application to the namespace of the Application that installed the // addon. The owned Application itself always lives in vela-system, so a // type: module component inside it installs its definitions here instead. // The module definition honors it only on Applications carrying // LabelAddonName. AnnotationModuleInstallNamespace = "modules.oam.dev/install-namespace" // AnnotationSkipResume annotation indicates that the resource does not need to be resumed. AnnotationSkipResume = "controller.core.oam.dev/skip-resume" // AnnotationReconcileInterval overrides the global ApplicationReSyncPeriod on a // per-application basis. The value must be a valid Go duration string (e.g. // "1m", "15m", "30s"). Values below 10s are ignored and fall back to the // global default. Invalid values are also ignored. AnnotationReconcileInterval = "app.oam.dev/reconcile-interval" )
const ( // ResourceTopologyFormatYAML mark the format of resource topology is yaml, by default, it's yaml. ResourceTopologyFormatYAML = "yaml" // ResourceTopologyFormatJSON mark the format of resource topology is json. ResourceTopologyFormatJSON = "json" )
const ( // FinalizerResourceTracker is the application finalizer for gc FinalizerResourceTracker = "app.oam.dev/resource-tracker-finalizer" // FinalizerOrphanResource indicates that the gc process should orphan managed // resources instead of deleting them FinalizerOrphanResource = "app.oam.dev/orphan-resource" )
const ( // SkipLastAppliedConfigDash is the "-" opt-out sentinel. SkipLastAppliedConfigDash = "-" // SkipLastAppliedConfigSkip is the "skip" opt-out sentinel. SkipLastAppliedConfigSkip = "skip" )
AnnotationLastAppliedConfig normally holds a serialized copy of the object as it was last dispatched, used as the original side of a three-way merge. These two values are read instead as a sentinel meaning "do not record my configuration".
const ( // AnnotationPlacement marks where an object installs. The value is // PlacementHub or PlacementRuntime. An object with no annotation is not // marked. AnnotationPlacement = "resource.oam.dev/placement" // PlacementHub stays on the control plane. PlacementHub = "hub" // PlacementRuntime follows the installer's placement request. PlacementRuntime = "runtime" )
const PolicyAdditionalContextKey policyContextKeyType = "kubevela.oam.dev/policy-additional-context"
PolicyAdditionalContextKey is the Go context key for storing policy output.ctx data.
Variables ¶
var ( // SystemDefinitionNamespace global value for controller and webhook system-level namespace SystemDefinitionNamespace = "vela-system" // ApplicationControllerName means the controller is application ApplicationControllerName = "vela-core" )
Functions ¶
func FilterInternalMetadata ¶ added in v1.11.0
FilterInternalMetadata returns a copy of metadata with internal platform keys removed. Returns nil when the result would be empty.
func GetCluster ¶ added in v1.2.0
GetCluster get cluster from object
func GetControllerRequirement ¶ added in v1.3.1
GetControllerRequirement get ControllerRequirement from object
func GetDeployVersion ¶ added in v1.3.1
GetDeployVersion get DeployVersion from object
func GetLastAppliedTime ¶ added in v1.3.1
GetLastAppliedTime .
func GetPublishVersion ¶ added in v1.3.0
GetPublishVersion get PublishVersion from object
func IsSkipLastAppliedConfig ¶
IsSkipLastAppliedConfig reports whether an AnnotationLastAppliedConfig value is the opt-out sentinel rather than a recorded configuration.
func SetCluster ¶ added in v1.2.0
SetCluster add cluster label to object
func SetClusterIfEmpty ¶ added in v1.9.0
SetClusterIfEmpty set cluster label to object if the label is empty
func SetControllerRequirement ¶ added in v1.3.1
SetControllerRequirement set ControllerRequirement for object
func SetPublishVersion ¶ added in v1.3.1
SetPublishVersion set PublishVersion for object
func ValidatePlacement ¶
ValidatePlacement accepts only PlacementHub and PlacementRuntime. An empty value and any other value are errors.
Types ¶
type Conditioned ¶ added in v0.2.0
type Conditioned interface {
SetConditions(c ...condition.Condition)
GetCondition(condition.ConditionType) condition.Condition
}
A Conditioned may have conditions set or retrieved. Conditions are typically indicate the status of both a resource and its reconciliation process.
type Finalizer ¶ added in v0.2.0
type Finalizer interface {
AddFinalizer(ctx context.Context, obj Object) error
RemoveFinalizer(ctx context.Context, obj Object) error
}
A Finalizer manages the finalizers on the resource.
type Trait ¶ added in v0.2.0
type Trait interface {
Object
Conditioned
WorkloadReferencer
}
A Trait is a type of OAM trait.
type TraitKind ¶ added in v0.2.0
type TraitKind schema.GroupVersionKind
TraitKind contains the type metadata for a kind of an OAM trait resource.
type Workload ¶ added in v0.2.0
type Workload interface {
Object
Conditioned
}
A Workload is a type of OAM workload.
type WorkloadKind ¶ added in v0.2.0
type WorkloadKind schema.GroupVersionKind
WorkloadKind contains the type metadata for a kind of an OAM workload resource.
type WorkloadReferencer ¶ added in v0.2.0
type WorkloadReferencer interface {
GetWorkloadReference() corev1.ObjectReference
SetWorkloadReference(corev1.ObjectReference)
}
A WorkloadReferencer may reference an OAM workload.
type WorkloadsReferencer ¶ added in v0.2.0
type WorkloadsReferencer interface {
GetWorkloadReferences() []corev1.ObjectReference
AddWorkloadReference(corev1.ObjectReference)
}
A WorkloadsReferencer may reference an OAM workload.