kubernetes: github.com/kwoodson/kubernetes/pkg/apiserver Index | Files

package apiserver

import "github.com/kwoodson/kubernetes/pkg/apiserver"

Package apiserver contains the code that provides a RESTful api service.

Index

Package Files

apiserver.go async.go authn.go authz.go doc.go errors.go handlers.go index.go interfaces.go mux_helper.go operation.go proxy.go redirect.go resthandler.go validator.go watch.go

Constants

const (
    ModeAlwaysAllow string = "AlwaysAllow"
    ModeAlwaysDeny  string = "AlwaysDeny"
    ModeABAC        string = "ABAC"
)
const (
    StatusUnprocessableEntity = 422
)

Variables

var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABAC}

Keep this list in sync with constant list above.

func APIVersionHandler Uses

func APIVersionHandler(versions ...string) restful.RouteFunction

APIVersionHandler returns a handler which will list the provided versions as available.

func AddApiWebService Uses

func AddApiWebService(container *restful.Container, apiPrefix string, versions []string)

Adds a service to return the supported api versions.

func CORS Uses

func CORS(handler http.Handler, allowedOriginPatterns []*regexp.Regexp, allowedMethods []string, allowedHeaders []string, allowCredentials string) http.Handler

TODO: use restful.CrossOriginResourceSharing Simple CORS implementation that wraps an http Handler For a more detailed implementation use https://github.com/martini-contrib/cors or implement CORS at your proxy layer Pass nil for allowedMethods and allowedHeaders to use the defaults

func Handle Uses

func Handle(storage map[string]RESTStorage, codec runtime.Codec, root string, version string, selfLinker runtime.SelfLinker, admissionControl admission.Interface) http.Handler

Handle returns a Handler function that exposes the provided storage interfaces as RESTful resources at prefix, serialized by codec, and also includes the support http resources. Note: This method is used only in tests.

func IndexHandler Uses

func IndexHandler(container *restful.Container, muxHelper *MuxHelper) func(http.ResponseWriter, *http.Request)

func InstallLogsSupport Uses

func InstallLogsSupport(mux Mux)

InstallLogsSupport registers the APIServer log support function into a mux.

func InstallSupport Uses

func InstallSupport(mux Mux, ws *restful.WebService)

TODO: document all handlers InstallSupport registers the APIServer support functions

func InstallValidator Uses

func InstallValidator(mux Mux, servers func() map[string]Server)

TODO: Convert to go-restful

func IsReadOnlyReq Uses

func IsReadOnlyReq(req http.Request) bool

IsReadOnlyReq() is true for any (or at least many) request which has no observable side effects on state of apiserver (though there may be internal side effects like caching and logging).

func KindAndNamespace Uses

func KindAndNamespace(req *http.Request) (namespace, kind string, parts []string, err error)

KindAndNamespace returns the kind, namespace, and path parts for the request relative to /{kind}/{name} Valid Inputs: Storage paths /ns/{namespace}/{kind} /ns/{namespace}/{kind}/{resourceName} /{kind} /{kind}/{resourceName} /{kind}/{resourceName}?namespace={namespace} /{kind}?namespace={namespace}

Special verbs: /proxy/{kind}/{resourceName} /proxy/ns/{namespace}/{kind}/{resourceName} /redirect/ns/{namespace}/{kind}/{resourceName} /redirect/{kind}/{resourceName} /watch/{kind} /watch/ns/{namespace}/{kind}

Fully qualified paths for above: /api/{version}/* /api/{version}/*

func MakeAsync Uses

func MakeAsync(fn WorkFunc) <-chan RESTResult

MakeAsync takes a function and executes it, delivering the result in the way required by RESTStorage's Update, Delete, and Create methods.

func MakeAsyncResult Uses

func MakeAsyncResult(fn WorkResultFunc) <-chan RESTResult

MakeAsync takes a function and executes it, delivering the result in the way required by RESTStorage's Update, Delete, and Create methods.

func NewAlwaysAllowAuthorizer Uses

func NewAlwaysAllowAuthorizer() authorizer.Authorizer

func NewAlwaysDenyAuthorizer Uses

func NewAlwaysDenyAuthorizer() authorizer.Authorizer

func NewAuthenticatorFromTokenFile Uses

func NewAuthenticatorFromTokenFile(tokenAuthFile string) (authenticator.Request, error)

NewAuthenticatorFromTokenFile returns an authenticator.Request or an error

func NewAuthorizerFromAuthorizationConfig Uses

func NewAuthorizerFromAuthorizationConfig(authorizationMode string, authorizationPolicyFile string) (authorizer.Authorizer, error)

NewAuthorizerFromAuthorizationConfig returns the right sort of authorizer.Authorizer based on the authorizationMode xor an error. authorizationMode should be one of AuthorizationModeChoices.

func NewValidator Uses

func NewValidator(servers func() map[string]Server) (http.Handler, error)

NewValidator creates a validator for a set of servers.

func RateLimit Uses

func RateLimit(rl util.RateLimiter, handler http.Handler) http.Handler

RateLimit uses rl to rate limit accepting requests to 'handler'.

func ReadOnly Uses

func ReadOnly(handler http.Handler) http.Handler

ReadOnly passes all GET requests on to handler, and returns an error on all other requests.

func RecoverPanics Uses

func RecoverPanics(handler http.Handler) http.Handler

RecoverPanics wraps an http Handler to recover and log panics.

func WithAuthorizationCheck Uses

func WithAuthorizationCheck(handler http.Handler, getAttribs RequestAttributeGetter, a authorizer.Authorizer) http.Handler

WithAuthorizationCheck passes all authorized requests on to handler, and returns a forbidden error otherwise.

type APIGroupVersion Uses

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

TODO: This is a whole API version right now. Maybe should rename it. APIGroupVersion is a http.Handler that exposes multiple RESTStorage objects It handles URLs of the form: /${storage_key}[/${object_name}] Where 'storage_key' points to a RESTStorage object stored in storage.

TODO: consider migrating this to go-restful which is a more full-featured version of the same thing.

func NewAPIGroupVersion Uses

func NewAPIGroupVersion(storage map[string]RESTStorage, codec runtime.Codec, canonicalPrefix string, selfLinker runtime.SelfLinker, admissionControl admission.Interface) *APIGroupVersion

NewAPIGroupVersion returns an object that will serve a set of REST resources and their associated operations. The provided codec controls serialization and deserialization. This is a helper method for registering multiple sets of REST handlers under different prefixes onto a server. TODO: add multitype codec serialization

func (*APIGroupVersion) InstallREST Uses

func (g *APIGroupVersion) InstallREST(container *restful.Container, mux Mux, root string, version string) error

InstallREST registers the REST handlers (storage, watch, and operations) into a restful Container. It is expected that the provided path root prefix will serve all operations. Root MUST NOT end in a slash. A restful WebService is created for the group and version.

type Attributes Uses

type Attributes struct {
}

Attributes implements authorizer.Attributes interface.

type Mux Uses

type Mux interface {
    Handle(pattern string, handler http.Handler)
    HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

mux is an object that can register http handlers.

type MuxHelper Uses

type MuxHelper struct {
    Mux             Mux
    RegisteredPaths []string
}

Offers additional functionality over ServeMux, for ex: supports listing registered paths.

func (*MuxHelper) Handle Uses

func (m *MuxHelper) Handle(path string, handler http.Handler)

func (*MuxHelper) HandleFunc Uses

func (m *MuxHelper) HandleFunc(path string, handler func(http.ResponseWriter, *http.Request))

type Operation Uses

type Operation struct {
    ID string
    // contains filtered or unexported fields
}

Operation represents an ongoing action which the server is performing.

func (*Operation) StatusOrResult Uses

func (op *Operation) StatusOrResult() (description RESTResult, finished bool)

StatusOrResult returns status information or the result of the operation if it is complete, with a bool indicating true in the latter case.

func (*Operation) WaitFor Uses

func (op *Operation) WaitFor(timeout time.Duration)

WaitFor waits for the specified duration, or until the operation finishes, whichever happens first.

type OperationHandler Uses

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

func (*OperationHandler) ServeHTTP Uses

func (h *OperationHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Operations Uses

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

Operations tracks all the ongoing operations.

func NewOperations Uses

func NewOperations() *Operations

NewOperations returns a new Operations repository.

func (*Operations) Get Uses

func (ops *Operations) Get(id string) *Operation

Get returns the operation with the given ID, or nil.

func (*Operations) List Uses

func (ops *Operations) List() *api.OperationList

List lists operations for an API client.

func (*Operations) NewOperation Uses

func (ops *Operations) NewOperation(from <-chan RESTResult, onReceive func(RESTResult)) *Operation

NewOperation adds a new operation. It is lock-free. 'onReceive' will be called with the value read from 'from', when it is read.

type ProxyHandler Uses

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

ProxyHandler provides a http.Handler which will proxy traffic to locations specified by items implementing Redirector.

func (*ProxyHandler) ServeHTTP Uses

func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RESTCreater Uses

type RESTCreater interface {
    // Create creates a new version of a resource.
    Create(ctx api.Context, obj runtime.Object) (<-chan RESTResult, error)
}

type RESTDeleter Uses

type RESTDeleter interface {
    // Delete finds a resource in the storage and deletes it.
    // Although it can return an arbitrary error value, IsNotFound(err) is true for the
    // returned error value err when the specified resource is not found.
    Delete(ctx api.Context, id string) (<-chan RESTResult, error)
}

type RESTGetter Uses

type RESTGetter interface {
    // Get finds a resource in the storage by id and returns it.
    // Although it can return an arbitrary error value, IsNotFound(err) is true for the
    // returned error value err when the specified resource is not found.
    Get(ctx api.Context, id string) (runtime.Object, error)
}

type RESTHandler Uses

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

RESTHandler implements HTTP verbs on a set of RESTful resources identified by name.

func (*RESTHandler) ServeHTTP Uses

func (h *RESTHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP handles requests to all RESTStorage objects.

type RESTLister Uses

type RESTLister interface {
    // NewList returns an empty object that can be used with the List call.
    // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
    NewList() runtime.Object
    // List selects resources in the storage which match to the selector.
    List(ctx api.Context, label, field labels.Selector) (runtime.Object, error)
}

type RESTResult Uses

type RESTResult struct {
    // The result of this operation. May be nil if the operation has no meaningful
    // result (like Delete)
    runtime.Object

    // May be set true to indicate that the Update operation resulted in the object
    // being created.
    Created bool
}

RESTResult indicates the result of a REST transformation.

type RESTStorage Uses

type RESTStorage interface {
    // New returns an empty object that can be used with Create and Update after request data has been put into it.
    // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
    New() runtime.Object
}

RESTStorage is a generic interface for RESTful storage services. Resources which are exported to the RESTful API of apiserver need to implement this interface. It is expected that objects may implement any of the REST* interfaces. TODO: implement dynamic introspection (so GenericREST objects can indicate what they implement)

type RESTUpdater Uses

type RESTUpdater interface {
    // Update finds a resource in the storage and updates it. Some implementations
    // may allow updates creates the object - they should set the Created flag of
    // the returned RESTResultto true. In the event of an asynchronous error returned
    // via an api.Status object, the Created flag is ignored.
    Update(ctx api.Context, obj runtime.Object) (<-chan RESTResult, error)
}

type RedirectHandler Uses

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

func (*RedirectHandler) ServeHTTP Uses

func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Redirector Uses

type Redirector interface {
    // ResourceLocation should return the remote location of the given resource, or an error.
    ResourceLocation(ctx api.Context, id string) (remoteLocation string, err error)
}

Redirector know how to return a remote resource's location.

type RequestAttributeGetter Uses

type RequestAttributeGetter interface {
    GetAttribs(req *http.Request) (attribs authorizer.Attributes)
}

RequestAttributeGetter is a function that extracts authorizer.Attributes from an http.Request

func NewRequestAttributeGetter Uses

func NewRequestAttributeGetter(userContexts authhandlers.RequestContext) RequestAttributeGetter

NewAttributeGetter returns an object which implements the RequestAttributeGetter interface.

type ResourceWatcher Uses

type ResourceWatcher interface {
    // 'label' selects on labels; 'field' selects on the object's fields. Not all fields
    // are supported; an error should be returned if 'field' tries to select on a field that
    // isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
    // particular version.
    Watch(ctx api.Context, label, field labels.Selector, resourceVersion string) (watch.Interface, error)
}

ResourceWatcher should be implemented by all RESTStorage objects that want to offer the ability to watch for changes through the watch api.

type Server Uses

type Server struct {
    Addr string
    Port int
    Path string
}

type ServerStatus Uses

type ServerStatus struct {
    Component  string        `json:"component,omitempty"`
    Health     string        `json:"health,omitempty"`
    HealthCode health.Status `json:"healthCode,omitempty"`
    Msg        string        `json:"msg,omitempty"`
    Err        string        `json:"err,omitempty"`
}

type WatchHandler Uses

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

func (*WatchHandler) ServeHTTP Uses

func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP processes watch requests.

type WatchServer Uses

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

WatchServer serves a watch.Interface over a websocket or vanilla HTTP.

func (*WatchServer) HandleWS Uses

func (w *WatchServer) HandleWS(ws *websocket.Conn)

HandleWS implements a websocket handler.

func (*WatchServer) ServeHTTP Uses

func (self *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves a series of JSON encoded events via straight HTTP with Transfer-Encoding: chunked.

type WorkFunc Uses

type WorkFunc func() (result runtime.Object, err error)

WorkFunc is used to perform any time consuming work for an api call, after the input has been validated. Pass one of these to MakeAsync to create an appropriate return value for the Update, Delete, and Create methods.

type WorkResultFunc Uses

type WorkResultFunc func() (result RESTResult, err error)

WorkFunc is used to perform any time consuming work for an api call, after the input has been validated. Pass one of these to MakeAsync to create an appropriate return value for the Update, Delete, and Create methods.

Package apiserver imports 44 packages (graph). Updated 2017-11-22. Refresh now. Tools for package owners.