application

package
v1.12.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 85 Imported by: 0

Documentation

Overview

Copyright 2026 The KubeVela Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2026 The KubeVela Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMutatingHandler

func RegisterMutatingHandler(mgr manager.Manager)

RegisterMutatingHandler will register component mutation handler to the webhook

func RegisterValidatingHandler

func RegisterValidatingHandler(mgr manager.Manager, _ controller.Args)

RegisterValidatingHandler will register application validate handler to the webhook

func RestrictionViolations

func RestrictionViolations(ctx context.Context, cli client.Client, app *v1beta1.Application) field.ErrorList

RestrictionViolations lists the definitions app uses, however it reaches them, that are restricted to other namespaces. The controller reports them on an Application admission let through; quotas, a budget for new uses, are left out.

func StepsCUEDepth added in v1.10.10

func StepsCUEDepth(path *field.Path, steps []wfTypesv1alpha1.WorkflowStep) field.ErrorList

StepsCUEDepth refuses workflow steps, and their sub-steps, whose condition or data passing carries CUE nested deeper than nesting.MaxDepth.

func ValidateCUEDepth added in v1.10.10

func ValidateCUEDepth(app *v1beta1.Application) field.ErrorList

ValidateCUEDepth refuses an Application whose workflow conditions or data passing carry CUE nested deeper than nesting.MaxDepth: the controller compiles them on every reconcile.

Types

type MutatingHandler

type MutatingHandler struct {
	Decoder admission.Decoder
	// contains filtered or unexported fields
}

MutatingHandler adding user info to application annotations

func (*MutatingHandler) Handle

Handle mutate application

type ReferencedObjectHandler added in v1.10.10

type ReferencedObjectHandler struct {
	Decoder admission.Decoder
	// contains filtered or unexported fields
}

ReferencedObjectHandler validates Workflow and Policy objects, which Applications reach by reference (spec.workflow.ref, a deploy step's policies). Whoever writes one must be able to use the definitions it names, and their namespace restrictions apply, as for an Application naming them inline; otherwise an Application admitted against a harmless object could have the object changed under it.

func (*ReferencedObjectHandler) Handle added in v1.10.10

Handle checks a created or updated Workflow or Policy. One the controller writes is checked for the Application that dispatched it: restrictions against that Application's namespace, and permissions as its author where that identity can be trusted.

type ValidatingHandler

type ValidatingHandler struct {
	Client client.Client
	// APIReader reads straight from the API server, used for the one Namespace
	// lookup a restriction's label selector needs. The cached client would start a
	// cluster-wide Namespace informer inside an admission request.
	APIReader client.Reader
	// Live is the same idea for definitions, as a full client rather than a
	// Reader: resolving a pinned revision asserts its reader back to a
	// client.Client. It sits behind the cache, not in front of it. Nil falls back
	// to Client.
	Live client.Client
	// Decoder decodes objects
	Decoder admission.Decoder
	// contains filtered or unexported fields
}

ValidatingHandler handles application

func (*ValidatingHandler) Handle

Handle validate Application Spec here

func (*ValidatingHandler) ValidateAbstractTypes

func (h *ValidatingHandler) ValidateAbstractTypes(ctx context.Context, app *v1beta1.Application) field.ErrorList

ValidateAbstractTypes refuses an Application that names a definition marked abstract.

An abstract definition is a base: it carries rules that whatever extends it must apply, so naming it directly is the way around them.

Only the type the Application names is judged. Extending an abstract definition is the point of marking one.

func (*ValidatingHandler) ValidateAddonComponents

func (h *ValidatingHandler) ValidateAddonComponents(
	ctx context.Context,
	app *v1beta1.Application,
) field.ErrorList

ValidateAddonComponents validates addon components when the feature is enabled.

func (*ValidatingHandler) ValidateAddonInstallers

func (h *ValidatingHandler) ValidateAddonInstallers(ctx context.Context, app *v1beta1.Application, req admission.Request) field.ErrorList

ValidateAddonInstallers refuses an addon component whose author may not install addons. The controller installs the addon with its own identity: the addon's Application in the system namespace and whatever cluster-scoped resources it holds. Creating Applications in the system namespace is what installing an addon takes, so the author must be able to do that themselves.

An Application the controller writes is judged for the one that dispatched it: one dispatched from the system namespace (an addon's own Application, installing what it depends on) may carry addon components; one dispatched from elsewhere is checked as that Application's author where the identity is trusted, and refused otherwise. One the controller writes for itself, outside dispatch, is not checked.

func (*ValidatingHandler) ValidateAnnotations added in v1.10.0

func (h *ValidatingHandler) ValidateAnnotations(ctx context.Context, app, oldApp *v1beta1.Application, req admission.Request) field.ErrorList

ValidateAnnotations validates whether the application has both autoupdate and publish version annotations

func (*ValidatingHandler) ValidateComponentNames

func (h *ValidatingHandler) ValidateComponentNames(_ context.Context, app *v1beta1.Application) field.ErrorList

ValidateComponentNames reports duplicated component names.

It reads only the Application, so it belongs to the soundness phase rather than behind appfile generation, where it would be reported only once every expression already type-checked.

func (*ValidatingHandler) ValidateComponents

func (h *ValidatingHandler) ValidateComponents(ctx context.Context, app *v1beta1.Application) field.ErrorList

ValidateComponents generates the appfile and renders it, which is the only way to learn what no static check can tell: that the templates evaluate, the traits apply, and the sources actually resolve.

It is the expensive half of validation and the destructive-adjacent one - source resolution here issues whatever HTTP, git or Kubernetes reads the definitions perform - so ValidateCreate does not call it until everything cheaper has passed.

func (*ValidatingHandler) ValidateCreate

func (h *ValidatingHandler) ValidateCreate(ctx context.Context, app *v1beta1.Application, req admission.Request) (field.ErrorList, []string)

ValidateCreate validates the Application on creation.

Validation runs in two phases, and the second is not attempted when the first finds anything:

soundness   is the Application well-formed?  expressions compile, their types
            fit the parameters they feed, sources are declared and ordered,
            names are unique, permissions hold
rendering   does it actually render?  generate the appfile, evaluate every
            template and trait, resolve every source for real

The gate earns its place twice. Rendering restates soundness failures in the evaluator's words and against a coarser field path, so the same mistake would be reported twice and the second telling is the worse one. And rendering is not free of consequence: resolving a source at admission issues whatever HTTP, git or Kubernetes reads its definition performs, so an Application already known to be invalid would still reach out to the world before being refused.

The cost is that a soundness failure hides any rendering failure until it is fixed - the usual compiler trade, fewer and more precise errors per round, and the reason the phases are named in the errors they produce.

func (*ValidatingHandler) ValidateDefinitionPermissions added in v1.10.4

func (h *ValidatingHandler) ValidateDefinitionPermissions(ctx context.Context, app *v1beta1.Application, req admission.Request) field.ErrorList

ValidateDefinitionPermissions validates that the user has permissions to access all definition types

func (*ValidatingHandler) ValidateDefinitionRestrictions

func (h *ValidatingHandler) ValidateDefinitionRestrictions(ctx context.Context, app, oldApp *v1beta1.Application) (field.ErrorList, []string)

ValidateDefinitionRestrictions rejects an Application that uses a definition restricted to other namespaces, or that would put its namespace over a quota. The warnings it returns are quotas asking to be flagged before they refuse.

Admission is the only place either is enforced, on update as well as create, so an Application admitted before a restriction keeps reconciling but is frozen.

Costs a Get per definition type, and a namespace List per type a quota governs.

func (*ValidatingHandler) ValidateEarlierTrackers

func (h *ValidatingHandler) ValidateEarlierTrackers(ctx context.Context, app *v1beta1.Application) field.ErrorList

ValidateEarlierTrackers refuses a new Application while ResourceTrackers of an earlier Application of its name and namespace remain, as a restore that included them leaves: the controller would refuse them on every reconcile. A tracker without the uid label is taken over by the next Application of the name, which is the remedy the refusal gives for a restore.

func (*ValidatingHandler) ValidateImmutableFields added in v1.11.0

func (h *ValidatingHandler) ValidateImmutableFields(ctx context.Context, newApp, oldApp *v1beta1.Application) field.ErrorList

ValidateImmutableFields validates that immutable parameter fields (`// +immutable`) have not changed All checks are bypassed if the app carries the app.oam.dev/force-mutate: "true" annotation.

func (*ValidatingHandler) ValidateModuleComponents

func (h *ValidatingHandler) ValidateModuleComponents(
	ctx context.Context,
	app *v1beta1.Application,
) field.ErrorList

ValidateModuleComponents validates module components when the feature is enabled.

func (*ValidatingHandler) ValidateSources

func (h *ValidatingHandler) ValidateSources(ctx context.Context, app *v1beta1.Application) field.ErrorList

ValidateSources validates source bindings and the source reads expressions make.

func (*ValidatingHandler) ValidateTimeout

func (h *ValidatingHandler) ValidateTimeout(name, timeout string) field.ErrorList

ValidateTimeout validates the timeout of steps

func (*ValidatingHandler) ValidateTraitConflicts added in v1.11.1

func (h *ValidatingHandler) ValidateTraitConflicts(ctx context.Context, app *v1beta1.Application) field.ErrorList

ValidateTraitConflicts validates TraitDefinition.spec.conflictsWith for traits attached to the same component. Kept outside ValidateComponents so it still runs when sharding skips component schematic validation.

func (*ValidatingHandler) ValidateUpdate

func (h *ValidatingHandler) ValidateUpdate(ctx context.Context, newApp, oldApp *v1beta1.Application, req admission.Request) (field.ErrorList, []string)

ValidateUpdate validates the Application on update

The immutable-field check is soundness, not rendering, so it gates the render alongside the rest rather than being reported after it.

An update that leaves the spec as it is cannot be refused for a problem the stored Application already has: a rule added since it was admitted would otherwise refuse every later label, annotation or publishVersion change, and only deletion would get past it. Such a problem is returned as a warning. The checks on who is asking, and any spec change, are enforced in full.

func (*ValidatingHandler) ValidateWorkflow

func (h *ValidatingHandler) ValidateWorkflow(_ context.Context, app *v1beta1.Application) field.ErrorList

ValidateWorkflow validates the Application workflow

Directories

Path Synopsis
Package addon holds the admission-time checks for type: addon Application components.
Package addon holds the admission-time checks for type: addon Application components.
Package module holds the admission-time checks for type: module Application components.
Package module holds the admission-time checks for type: module Application components.

Jump to

Keyboard shortcuts

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