admission

package
v1.4.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

Functions

func GetPlugins

func GetPlugins() []string

GetPlugins enumerates the names of all registered plugins.

func NewForbidden added in v0.16.0

func NewForbidden(a Attributes, internalError error) error

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

func NewNotFound added in v1.1.0

func NewNotFound(a Attributes) error

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

func RegisterPlugin

func RegisterPlugin(name string, plugin Factory)

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

func Validate added in v1.4.0

func Validate(plugins []Interface) error

Validate will call the Validate function in each plugin if they implement the Validator interface.

Types

type Attributes

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() unversioned.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
	// 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() unversioned.GroupVersionKind
	// GetUserInfo is information about the requesting user
	GetUserInfo() user.Info
}

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

func NewAttributesRecord

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

type Factory

type Factory func(client clientset.Interface, 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 added in v0.18.0

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 added in v0.18.0

func NewHandler(ops ...Operation) *Handler

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

func (*Handler) Handles added in v0.18.0

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

Handles returns true for methods that this handler supports

func (*Handler) SetReadyFunc added in v1.4.0

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 added in v1.4.0

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 Interface

type Interface interface {
	// Admit makes an admission decision based on the request attributes
	Admit(a Attributes) (err error)

	// 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 InitPlugin

func InitPlugin(name string, client clientset.Interface, configFilePath string) Interface

InitPlugin creates an instance of the named interface.

func NewChainHandler added in v0.18.0

func NewChainHandler(handlers ...Interface) Interface

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

func NewFromPlugins

func NewFromPlugins(client clientset.Interface, pluginNames []string, configFilePath string, plugInit PluginInitializer) (Interface, error)

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

type Operation added in v0.18.0

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 added in v1.3.0

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 added in v1.4.0

type PluginInitializer interface {
	Initialize(plugins []Interface)
}

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

func NewPluginInitializer added in v1.4.0

func NewPluginInitializer(sharedInformers informers.SharedInformerFactory) PluginInitializer

NewPluginInitializer constructs new instance of PluginInitializer

type ReadyFunc added in v1.4.0

type ReadyFunc func() bool

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

type Validator added in v1.4.0

type Validator interface {
	Validate() error
}

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

type WantsInformerFactory added in v1.4.0

type WantsInformerFactory interface {
	SetInformerFactory(informers.SharedInformerFactory)
	Validator
}

WantsInformerFactory defines a function which sets InformerFactory for admission plugins that need it

Jump to

Keyboard shortcuts

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