apiserver: k8s.io/apiserver/pkg/admission Index | Files | Directories

package admission

import "k8s.io/apiserver/pkg/admission"

Index

Package Files

attributes.go audit.go chain.go config.go decorator.go errors.go handler.go interfaces.go plugins.go reinvocation.go util.go

Variables

var (
    // PluginEnabledFn checks whether a plugin is enabled.  By default, if you ask about it, it's enabled.
    PluginEnabledFn = func(name string, config io.Reader) bool {
        return true
    }
)

All registered admission options.

func GetAdmissionPluginConfigurationFor Uses

func GetAdmissionPluginConfigurationFor(pluginCfg apiserver.AdmissionPluginConfiguration) (io.Reader, error)

GetAdmissionPluginConfigurationFor returns a reader that holds the admission plugin configuration.

func NewChainHandler Uses

func NewChainHandler(handlers ...Interface) chainAdmissionHandler

NewChainHandler creates a new chain handler from an array of handlers. Used for testing.

func NewForbidden Uses

func NewForbidden(a Attributes, internalError error) error

NewForbidden is a utility function to return a well-formatted admission control error response

func NewNotFound Uses

func NewNotFound(a Attributes) error

NewNotFound is a utility function to return a well-formatted admission control error response

func ValidateInitialization Uses

func ValidateInitialization(plugin Interface) error

ValidateInitialization will call the InitializationValidate function in each plugin if they implement the InitializationValidator interface.

type AnnotationsGetter Uses

type AnnotationsGetter interface {
    GetAnnotations(maxLevel auditinternal.Level) map[string]string
}

AnnotationsGetter allows users to get annotations from Attributes. An alternate Attribute should implement this interface.

type Attributes Uses

type Attributes interface {
    // GetName returns the name of the object as presented in the request.  On a CREATE operation, the client
    // may omit name and rely on the server to generate the name.  If that is the case, this method will return
    // the empty string
    GetName() string
    // GetNamespace is the namespace associated with the request (if any)
    GetNamespace() string
    // GetResource is the name of the resource being requested.  This is not the kind.  For example: pods
    GetResource() schema.GroupVersionResource
    // GetSubresource is the name of the subresource being requested.  This is a different resource, scoped to the parent resource, but it may have a different kind.
    // For instance, /pods has the resource "pods" and the kind "Pod", while /pods/foo/status has the resource "pods", the sub resource "status", and the kind "Pod"
    // (because status operates on pods). The binding resource for a pod though may be /pods/foo/binding, which has resource "pods", subresource "binding", and kind "Binding".
    GetSubresource() string
    // GetOperation is the operation being performed
    GetOperation() Operation
    // GetOperationOptions is the options for the operation being performed
    GetOperationOptions() runtime.Object
    // IsDryRun indicates that modifications will definitely not be persisted for this request. This is to prevent
    // admission controllers with side effects and a method of reconciliation from being overwhelmed.
    // However, a value of false for this does not mean that the modification will be persisted, because it
    // could still be rejected by a subsequent validation step.
    IsDryRun() bool
    // GetObject is the object from the incoming request prior to default values being applied
    GetObject() runtime.Object
    // GetOldObject is the existing object. Only populated for UPDATE requests.
    GetOldObject() runtime.Object
    // GetKind is the type of object being manipulated.  For example: Pod
    GetKind() schema.GroupVersionKind
    // GetUserInfo is information about the requesting user
    GetUserInfo() user.Info

    // AddAnnotation sets annotation according to key-value pair. The key should be qualified, e.g., podsecuritypolicy.admission.k8s.io/admit-policy, where
    // "podsecuritypolicy" is the name of the plugin, "admission.k8s.io" is the name of the organization, "admit-policy" is the key name.
    // An error is returned if the format of key is invalid. When trying to overwrite annotation with a new value, an error is returned.
    // Both ValidationInterface and MutationInterface are allowed to add Annotations.
    // By default, an annotation gets logged into audit event if the request's audit level is greater or
    // equal to Metadata.
    AddAnnotation(key, value string) error

    // AddAnnotationWithLevel sets annotation according to key-value pair with additional intended audit level.
    // An Annotation gets logged into audit event if the request's audit level is greater or equal to the
    // intended audit level.
    AddAnnotationWithLevel(key, value string, level auditinternal.Level) error

    // GetReinvocationContext tracks the admission request information relevant to the re-invocation policy.
    GetReinvocationContext() ReinvocationContext
}

Attributes is an interface used by AdmissionController to get information about a request that is used to make an admission decision.

func NewAttributesRecord Uses

func NewAttributesRecord(object runtime.Object, oldObject runtime.Object, kind schema.GroupVersionKind, namespace, name string, resource schema.GroupVersionResource, subresource string, operation Operation, operationOptions runtime.Object, dryRun bool, userInfo user.Info) Attributes

type ConfigProvider Uses

type ConfigProvider interface {
    ConfigFor(pluginName string) (io.Reader, error)
}

ConfigProvider provides a way to get configuration for an admission plugin based on its name

func ReadAdmissionConfiguration Uses

func ReadAdmissionConfiguration(pluginNames []string, configFilePath string, configScheme *runtime.Scheme) (ConfigProvider, error)

ReadAdmissionConfiguration reads the admission configuration at the specified path. It returns the loaded admission configuration if the input file aligns with the required syntax. If it does not align with the provided syntax, it returns a default configuration for the enumerated set of pluginNames whose config location references the specified configFilePath. It does this to preserve backward compatibility when admission control files were opaque. It returns an error if the file did not exist.

type Decorator Uses

type Decorator interface {
    Decorate(handler Interface, name string) Interface
}

type DecoratorFunc Uses

type DecoratorFunc func(handler Interface, name string) Interface

func (DecoratorFunc) Decorate Uses

func (d DecoratorFunc) Decorate(handler Interface, name string) Interface

type Decorators Uses

type Decorators []Decorator

func (Decorators) Decorate Uses

func (d Decorators) Decorate(handler Interface, name string) Interface

Decorate applies the decorator in inside-out order, i.e. the first decorator in the slice is first applied to the given handler.

type Factory Uses

type Factory func(config io.Reader) (Interface, error)

Factory is a function that returns an Interface for admission decisions. The config parameter provides an io.Reader handler to the factory in order to load specific configurations. If no configuration is provided the parameter is nil.

type Handler Uses

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

Handler is a base for admission control handlers that support a predefined set of operations

func NewHandler Uses

func NewHandler(ops ...Operation) *Handler

NewHandler creates a new base handler that handles the passed in operations

func (*Handler) Handles Uses

func (h *Handler) Handles(operation Operation) bool

Handles returns true for methods that this handler supports

func (*Handler) SetReadyFunc Uses

func (h *Handler) SetReadyFunc(readyFunc ReadyFunc)

SetReadyFunc allows late registration of a ReadyFunc to know if the handler is ready to process requests.

func (*Handler) WaitForReady Uses

func (h *Handler) WaitForReady() bool

WaitForReady will wait for the readyFunc (if registered) to return ready, and in case of timeout, will return false.

type InitializationValidator Uses

type InitializationValidator interface {
    ValidateInitialization() error
}

InitializationValidator holds ValidateInitialization functions, which are responsible for validation of initialized shared resources and should be implemented on admission plugins

type Interface Uses

type Interface interface {
    // Handles returns true if this admission controller can handle the given operation
    // where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
    Handles(operation Operation) bool
}

Interface is an abstract, pluggable interface for Admission Control decisions.

func WithAudit Uses

func WithAudit(i Interface, ae *auditinternal.Event) Interface

WithAudit is a decorator for a admission phase. It saves annotations of attribute into the audit event. Attributes passed to the Admit and Validate function must be instance of privateAnnotationsGetter or AnnotationsGetter, otherwise an error is returned.

type MutationInterface Uses

type MutationInterface interface {
    Interface

    // Admit makes an admission decision based on the request attributes.
    // Context is used only for timeout/deadline/cancellation and tracing information.
    Admit(ctx context.Context, a Attributes, o ObjectInterfaces) (err error)
}

type ObjectInterfaces Uses

type ObjectInterfaces interface {
    // GetObjectCreater is the ObjectCreator appropriate for the requested object.
    GetObjectCreater() runtime.ObjectCreater
    // GetObjectTyper is the ObjectTyper appropriate for the requested object.
    GetObjectTyper() runtime.ObjectTyper
    // GetObjectDefaulter is the ObjectDefaulter appropriate for the requested object.
    GetObjectDefaulter() runtime.ObjectDefaulter
    // GetObjectConvertor is the ObjectConvertor appropriate for the requested object.
    GetObjectConvertor() runtime.ObjectConvertor
    // GetEquivalentResourceMapper is the EquivalentResourceMapper appropriate for finding equivalent resources and expected kind for the requested object.
    GetEquivalentResourceMapper() runtime.EquivalentResourceMapper
}

ObjectInterfaces is an interface used by AdmissionController to get object interfaces such as Converter or Defaulter. These interfaces are normally coming from Request Scope to handle special cases like CRDs.

func NewObjectInterfacesFromScheme Uses

func NewObjectInterfacesFromScheme(scheme *runtime.Scheme) ObjectInterfaces

type Operation Uses

type Operation string

Operation is the type of resource operation being checked for admission control

const (
    Create  Operation = "CREATE"
    Update  Operation = "UPDATE"
    Delete  Operation = "DELETE"
    Connect Operation = "CONNECT"
)

Operation constants

type PluginEnabledFunc Uses

type PluginEnabledFunc func(name string, config io.Reader) bool

PluginEnabledFunc is a function type that can provide an external check on whether an admission plugin may be enabled

type PluginInitializer Uses

type PluginInitializer interface {
    Initialize(plugin Interface)
}

PluginInitializer is used for initialization of shareable resources between admission plugins. After initialization the resources have to be set separately

type PluginInitializers Uses

type PluginInitializers []PluginInitializer

func (PluginInitializers) Initialize Uses

func (pp PluginInitializers) Initialize(plugin Interface)

type Plugins Uses

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

func NewPlugins Uses

func NewPlugins() *Plugins

func (*Plugins) InitPlugin Uses

func (ps *Plugins) InitPlugin(name string, config io.Reader, pluginInitializer PluginInitializer) (Interface, error)

InitPlugin creates an instance of the named interface.

func (*Plugins) NewFromPlugins Uses

func (ps *Plugins) NewFromPlugins(pluginNames []string, configProvider ConfigProvider, pluginInitializer PluginInitializer, decorator Decorator) (Interface, error)

NewFromPlugins returns an admission.Interface that will enforce admission control decisions of all the given plugins.

func (*Plugins) Register Uses

func (ps *Plugins) Register(name string, plugin Factory)

Register registers a plugin Factory by name. This is expected to happen during app startup.

func (*Plugins) Registered Uses

func (ps *Plugins) Registered() []string

Registered enumerates the names of all registered plugins.

type ReadyFunc Uses

type ReadyFunc func() bool

ReadyFunc is a function that returns true if the admission controller is ready to handle requests.

type ReinvocationContext Uses

type ReinvocationContext interface {
    // IsReinvoke returns true if the current admission check is a re-invocation.
    IsReinvoke() bool
    // SetIsReinvoke sets the current admission check as a re-invocation.
    SetIsReinvoke()
    // ShouldReinvoke returns true if any plugin has requested a re-invocation.
    ShouldReinvoke() bool
    // SetShouldReinvoke signals that a re-invocation is desired.
    SetShouldReinvoke()
    // AddValue set a value for a plugin name, possibly overriding a previous value.
    SetValue(plugin string, v interface{})
    // Value reads a value for a webhook.
    Value(plugin string) interface{}
}

ReinvocationContext provides access to the admission related state required to implement the re-invocation policy.

type RuntimeObjectInterfaces Uses

type RuntimeObjectInterfaces struct {
    runtime.ObjectCreater
    runtime.ObjectTyper
    runtime.ObjectDefaulter
    runtime.ObjectConvertor
    runtime.EquivalentResourceMapper
}

func (*RuntimeObjectInterfaces) GetEquivalentResourceMapper Uses

func (r *RuntimeObjectInterfaces) GetEquivalentResourceMapper() runtime.EquivalentResourceMapper

func (*RuntimeObjectInterfaces) GetObjectConvertor Uses

func (r *RuntimeObjectInterfaces) GetObjectConvertor() runtime.ObjectConvertor

func (*RuntimeObjectInterfaces) GetObjectCreater Uses

func (r *RuntimeObjectInterfaces) GetObjectCreater() runtime.ObjectCreater

func (*RuntimeObjectInterfaces) GetObjectDefaulter Uses

func (r *RuntimeObjectInterfaces) GetObjectDefaulter() runtime.ObjectDefaulter

func (*RuntimeObjectInterfaces) GetObjectTyper Uses

func (r *RuntimeObjectInterfaces) GetObjectTyper() runtime.ObjectTyper

type ValidationInterface Uses

type ValidationInterface interface {
    Interface

    // Validate makes an admission decision based on the request attributes.  It is NOT allowed to mutate
    // Context is used only for timeout/deadline/cancellation and tracing information.
    Validate(ctx context.Context, a Attributes, o ObjectInterfaces) (err error)
}

ValidationInterface is an abstract, pluggable interface for Admission Control decisions.

Directories

PathSynopsis
configuration
initializer
metrics
plugin/namespace/lifecycle
plugin/webhook
plugin/webhook/config
plugin/webhook/config/apis/webhookadmission
plugin/webhook/config/apis/webhookadmission/installPackage install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
plugin/webhook/config/apis/webhookadmission/v1Package v1 is the v1 version of the API.
plugin/webhook/config/apis/webhookadmission/v1alpha1Package v1alpha1 is the v1alpha1 version of the API.
plugin/webhook/errorsPackage errors contains utilities for admission webhook specific errors
plugin/webhook/generic
plugin/webhook/initializer
plugin/webhook/mutatingPackage mutating delegates admission checks to dynamically configured mutating webhooks.
plugin/webhook/namespacePackage namespace defines the utilities that are used by the webhook plugin to decide if a webhook should be applied to an object based on its namespace.
plugin/webhook/objectPackage object defines the utilities that are used by the webhook plugin to decide if a webhook should run, as long as either the old object or the new object has labels matching the webhook config's objectSelector.
plugin/webhook/requestPackage request creates admissionReview request based on admission attributes.
plugin/webhook/rules
plugin/webhook/testcertsPackage testcerts contains generated key pairs used by the unit tests of mutating and validating webhooks.
plugin/webhook/testing
plugin/webhook/testing/main
plugin/webhook/util
plugin/webhook/validatingPackage validating makes calls to validating (i.e., non-mutating) webhooks during the admission process.
testing

Package admission imports 28 packages (graph) and is imported by 809 packages. Updated 2019-11-18. Refresh now. Tools for package owners.