types

package
v1.4.0-dev-20240819 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 16

Documentation

Index

Constants

View Source
const (
	AdmissionTypeMutation   = "mutation"
	AdmissionTypeValidation = "validation"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmissionHandler

type AdmissionHandler struct {
	// contains filtered or unexported fields
}

func NewAdmissionHandler

func NewAdmissionHandler(admitter Admitter, admissionType string, options *config.Options) *AdmissionHandler

func (*AdmissionHandler) Admit

func (v *AdmissionHandler) Admit(response *webhook.Response, request *webhook.Request) error

type Admitter

type Admitter interface {
	// Create checks if a CREATE operation is allowed.
	// PatchOps contains JSON patch operations to be applied on the API object received by the server.
	// If no error is returned, the operation is allowed.
	Create(request *Request, newObj runtime.Object) (PatchOps, error)

	// Update checks if a UPDATE operation is allowed.
	// PatchOps contains JSON patch operations to be applied on the API object received by the server.
	// If no error is returned, the operation is allowed.
	Update(request *Request, oldObj runtime.Object, newObj runtime.Object) (PatchOps, error)

	// Delete checks if a DELETE operation is allowed.
	// PatchOps contains JSON patch operations to be applied on the API object received by the server.
	// If no error is returned, the operation is allowed.
	Delete(request *Request, oldObj runtime.Object) (PatchOps, error)

	// Connect checks if a CONNECT operation is allowed.
	// PatchOps contains JSON patch operations to be applied on the API object received by the server.
	// If no error is returned, the operation is allowed.
	Connect(request *Request, newObj runtime.Object) (PatchOps, error)

	// Resource returns the resource that the admitter works on.
	Resource() Resource
}

A Admitter interface is used by AdmissionHandler to check if a operation is allowed.

type DefaultMutator

type DefaultMutator struct {
}

DefaultMutator allows every supported operation and mutate nothing

func (*DefaultMutator) Connect

func (v *DefaultMutator) Connect(_ *Request, _ runtime.Object) (PatchOps, error)

func (*DefaultMutator) Create

func (v *DefaultMutator) Create(_ *Request, _ runtime.Object) (PatchOps, error)

func (*DefaultMutator) Delete

func (v *DefaultMutator) Delete(_ *Request, _ runtime.Object) (PatchOps, error)

func (*DefaultMutator) Update

type DefaultValidator

type DefaultValidator struct {
}

DefaultValidator allows every supported operation.

func (*DefaultValidator) Connect

func (v *DefaultValidator) Connect(_ *Request, _ runtime.Object) error

func (*DefaultValidator) Create

func (v *DefaultValidator) Create(_ *Request, _ runtime.Object) error

func (*DefaultValidator) Delete

func (v *DefaultValidator) Delete(_ *Request, _ runtime.Object) error

func (*DefaultValidator) Update

type Mutator

type Mutator Admitter

func NewValidatorAdapter

func NewValidatorAdapter(validator Validator) Mutator

type PatchOps

type PatchOps []string

JSON Patch operations to mutate input data. See https://jsonpatch.com/ for more information.

type Request

type Request struct {
	*webhook.Request
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(webhookRequest *webhook.Request, options *config.Options) *Request

func (*Request) DecodeObjects

func (r *Request) DecodeObjects() (oldObj runtime.Object, newObj runtime.Object, err error)

func (*Request) IsFromController

func (r *Request) IsFromController() bool

func (*Request) IsGarbageCollection

func (r *Request) IsGarbageCollection() bool

func (*Request) String

func (r *Request) String() string

func (*Request) Username

func (r *Request) Username() string

type Resource

type Resource struct {
	Names          []string
	Scope          admissionregv1.ScopeType
	APIGroup       string
	APIVersion     string
	ObjectType     runtime.Object
	OperationTypes []admissionregv1.OperationType
}

func (Resource) Validate

func (r Resource) Validate() error

type Validator

type Validator interface {
	// Create checks if a CREATE operation is allowed. If no error is returned, the operation is allowed.
	Create(request *Request, newObj runtime.Object) error

	// Update checks if a UPDATE operation is allowed. If no error is returned, the operation is allowed.
	Update(request *Request, oldObj runtime.Object, newObj runtime.Object) error

	// Delete checks if a DELETE operation is allowed. If no error is returned, the operation is allowed.
	Delete(request *Request, oldObj runtime.Object) error

	// Connect checks if a CONNECT operation is allowed. If no error is returned, the operation is allowed.
	Connect(request *Request, newObj runtime.Object) error

	Resource() Resource
}

Validator is a Mutator that doesn't modify received API objects.

type ValidatorAdapter

type ValidatorAdapter struct {
	// contains filtered or unexported fields
}

ValidatorAdapter adapts a Validator to an Admitter.

func (*ValidatorAdapter) Connect

func (c *ValidatorAdapter) Connect(request *Request, newObj runtime.Object) (PatchOps, error)

func (*ValidatorAdapter) Create

func (c *ValidatorAdapter) Create(request *Request, newObj runtime.Object) (PatchOps, error)

func (*ValidatorAdapter) Delete

func (c *ValidatorAdapter) Delete(request *Request, oldObj runtime.Object) (PatchOps, error)

func (*ValidatorAdapter) Resource

func (c *ValidatorAdapter) Resource() Resource

func (*ValidatorAdapter) Update

func (c *ValidatorAdapter) Update(request *Request, oldObj runtime.Object, newObj runtime.Object) (PatchOps, error)

Jump to

Keyboard shortcuts

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