Documentation
¶
Overview ¶
Package handlers implements the specific business logic for Kubernetes Admission Control.
It contains implementations of the controller-runtime 'admission.Handler' interface for two primary purposes:
Mutation (Defaulters): These handlers intercept CREATE and UPDATE requests to apply default values to resources. They rely heavily on the 'pkg/resolver' module to ensure that defaults applied at admission time are identical to those applied by the Reconciler during operation. (See: MultigresClusterDefaulter).
Validation (Validators): These handlers intercept CREATE, UPDATE, and DELETE requests to enforce semantic rules that cannot be expressed in OpenAPI schemas (CRD Level 1) or CEL (CRD Level 2). This includes: - Stateful Validation: Checks requiring lookups of other objects (e.g., preventing deletion of a template that is in use). - Context-Aware Validation: Checks requiring access to request metadata (e.g., UserInfo) or old object states, serving as a fallback for clusters that do not support 'ValidatingAdmissionPolicy'.
Index ¶
- type ChildResourceValidator
- func (v *ChildResourceValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *ChildResourceValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *ChildResourceValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
- type MultigresClusterDefaulter
- type MultigresClusterValidator
- func (v *MultigresClusterValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *MultigresClusterValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *MultigresClusterValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
- type TemplateValidator
- func (v *TemplateValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *TemplateValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (v *TemplateValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChildResourceValidator ¶
type ChildResourceValidator struct {
// contains filtered or unexported fields
}
ChildResourceValidator prevents direct modification of managed child resources.
func NewChildResourceValidator ¶
func NewChildResourceValidator(exemptPrincipals ...string) *ChildResourceValidator
NewChildResourceValidator creates a validator that blocks direct modification of managed child resources.
func (*ChildResourceValidator) ValidateCreate ¶
func (v *ChildResourceValidator) ValidateCreate( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateCreate rejects direct creation of managed child resources.
func (*ChildResourceValidator) ValidateDelete ¶
func (v *ChildResourceValidator) ValidateDelete( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateDelete rejects direct deletion of managed child resources.
func (*ChildResourceValidator) ValidateUpdate ¶
func (v *ChildResourceValidator) ValidateUpdate( ctx context.Context, oldObj, newObj runtime.Object, ) (admission.Warnings, error)
ValidateUpdate rejects direct modification of managed child resources.
type MultigresClusterDefaulter ¶
MultigresClusterDefaulter handles the mutation of MultigresCluster resources.
func NewMultigresClusterDefaulter ¶
func NewMultigresClusterDefaulter(r *resolver.Resolver) *MultigresClusterDefaulter
NewMultigresClusterDefaulter creates a new defaulter handler.
type MultigresClusterValidator ¶
MultigresClusterValidator validates Create and Update events for MultigresClusters.
func NewMultigresClusterValidator ¶
func NewMultigresClusterValidator(c client.Client) *MultigresClusterValidator
NewMultigresClusterValidator creates a new validator for MultigresClusters.
func (*MultigresClusterValidator) ValidateCreate ¶
func (v *MultigresClusterValidator) ValidateCreate( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateCreate validates a MultigresCluster on creation.
func (*MultigresClusterValidator) ValidateDelete ¶
func (v *MultigresClusterValidator) ValidateDelete( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateDelete is a no-op for MultigresCluster deletion.
func (*MultigresClusterValidator) ValidateUpdate ¶
func (v *MultigresClusterValidator) ValidateUpdate( ctx context.Context, oldObj, newObj runtime.Object, ) (admission.Warnings, error)
ValidateUpdate validates a MultigresCluster on update, including storage shrink and etcd replica checks.
type TemplateValidator ¶
TemplateValidator validates Delete events to ensure templates are not in use.
func NewTemplateValidator ¶
func NewTemplateValidator(c client.Client, kind string) *TemplateValidator
NewTemplateValidator creates a validator that prevents deletion of in-use templates.
func (*TemplateValidator) ValidateCreate ¶
func (v *TemplateValidator) ValidateCreate( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateCreate validates pool name map keys for ShardTemplates on creation.
func (*TemplateValidator) ValidateDelete ¶
func (v *TemplateValidator) ValidateDelete( ctx context.Context, obj runtime.Object, ) (admission.Warnings, error)
ValidateDelete rejects deletion of templates that are referenced by a MultigresCluster.
func (*TemplateValidator) ValidateUpdate ¶
func (v *TemplateValidator) ValidateUpdate( ctx context.Context, oldObj, newObj runtime.Object, ) (admission.Warnings, error)
ValidateUpdate validates pool name map keys for ShardTemplates on update.