Documentation ¶
Overview ¶
Package apiserver contains the code that provides a rest.ful api service.
Index ¶
- Constants
- func APIVersionHandler(s runtime.NegotiatedSerializer, ...) restful.RouteFunction
- func AddApiWebService(s runtime.NegotiatedSerializer, container *restful.Container, apiPrefix string, ...)
- func AddSupportedResourcesWebService(s runtime.NegotiatedSerializer, ws *restful.WebService, ...)
- func ConnectResource(connecter rest.Connecter, scope RequestScope, admit admission.Interface, ...) restful.RouteFunction
- func CreateNamedResource(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, ...) restful.RouteFunction
- func CreateResource(r rest.Creater, scope RequestScope, typer runtime.ObjectTyper, ...) restful.RouteFunction
- func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestScope, ...) restful.RouteFunction
- func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestScope, ...) restful.RouteFunction
- func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) restful.RouteFunction
- func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope) restful.RouteFunction
- func GroupHandler(s runtime.NegotiatedSerializer, group unversioned.APIGroup) restful.RouteFunction
- func InstallRecoverHandler(s runtime.NegotiatedSerializer, container *restful.Container)
- func InstallServiceErrorHandler(s runtime.NegotiatedSerializer, container *restful.Container)
- func IsAPIPrefixNotFound(err error) bool
- func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch bool, ...) restful.RouteFunction
- func NewApisWebService(s runtime.NegotiatedSerializer, apiPrefix string, ...) *restful.WebService
- func NewGroupWebService(s runtime.NegotiatedSerializer, path string, group unversioned.APIGroup) *restful.WebService
- func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper, ...) restful.RouteFunction
- func RootAPIHandler(s runtime.NegotiatedSerializer, ...) restful.RouteFunction
- func SupportedResourcesHandler(s runtime.NegotiatedSerializer, groupVersion unversioned.GroupVersion, ...) restful.RouteFunction
- func UpdateResource(r rest.Updater, scope RequestScope, typer runtime.ObjectTyper, ...) restful.RouteFunction
- func WriteRawJSON(statusCode int, object interface{}, w http.ResponseWriter)
- type APIGroupVersion
- type APIInstaller
- type APIResourceLister
- type ContextFunc
- type ProxyDialerFunc
- type ProxyHandler
- type RequestScope
- type ScopeNamer
- type Server
- type ServerStatus
- type StripVersionNegotiatedSerializer
- type ValidatorFn
- type WatchServer
Constants ¶
const ( // Minimum duration before timing out read/write requests MinTimeoutSecs = 300 // Maximum duration before timing out read/write requests MaxTimeoutSecs = 600 )
TODO: Pipe these in through the apiserver cmd line
const MaxPatchConflicts = 5
MaxPatchConflicts is the maximum number of conflicts retry for during a patch operation before returning failure
Variables ¶
This section is empty.
Functions ¶
func APIVersionHandler ¶ added in v0.5.1
func APIVersionHandler(s runtime.NegotiatedSerializer, getAPIVersionsFunc func(req *restful.Request) *unversioned.APIVersions) restful.RouteFunction
APIVersionHandler returns a handler which will list the provided versions as available.
func AddApiWebService ¶ added in v0.9.0
func AddApiWebService(s runtime.NegotiatedSerializer, container *restful.Container, apiPrefix string, getAPIVersionsFunc func(req *restful.Request) *unversioned.APIVersions)
Adds a service to return the supported api versions at the legacy /api.
func AddSupportedResourcesWebService ¶ added in v1.1.0
func AddSupportedResourcesWebService(s runtime.NegotiatedSerializer, ws *restful.WebService, groupVersion unversioned.GroupVersion, lister APIResourceLister)
Adds a service to return the supported resources, E.g., a such web service will be registered at /apis/extensions/v1.
func ConnectResource ¶ added in v0.16.0
func ConnectResource(connecter rest.Connecter, scope RequestScope, admit admission.Interface, restPath string) restful.RouteFunction
ConnectResource returns a function that handles a connect request on a rest.Storage object.
func CreateNamedResource ¶ added in v0.17.0
func CreateNamedResource(r rest.NamedCreater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) restful.RouteFunction
CreateNamedResource returns a function that will handle a resource creation with name.
func CreateResource ¶ added in v0.11.0
func CreateResource(r rest.Creater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) restful.RouteFunction
CreateResource returns a function that will handle a resource creation.
func DeleteCollection ¶ added in v1.2.0
func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestScope, admit admission.Interface) restful.RouteFunction
DeleteCollection returns a function that will handle a collection deletion
func DeleteResource ¶ added in v0.11.0
func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestScope, admit admission.Interface) restful.RouteFunction
DeleteResource returns a function that will handle a resource deletion
func GetResource ¶ added in v0.11.0
func GetResource(r rest.Getter, e rest.Exporter, scope RequestScope) restful.RouteFunction
GetResource returns a function that handles retrieving a single resource from a rest.Storage object.
func GetResourceWithOptions ¶ added in v0.15.0
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope) restful.RouteFunction
GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object.
func GroupHandler ¶ added in v1.1.0
func GroupHandler(s runtime.NegotiatedSerializer, group unversioned.APIGroup) restful.RouteFunction
GroupHandler returns a handler which will return the api.GroupAndVersion of the group.
func InstallRecoverHandler ¶ added in v1.1.0
func InstallRecoverHandler(s runtime.NegotiatedSerializer, container *restful.Container)
TODO: needs to perform response type negotiation, this is probably the wrong way to recover panics
func InstallServiceErrorHandler ¶ added in v0.16.0
func InstallServiceErrorHandler(s runtime.NegotiatedSerializer, container *restful.Container)
func IsAPIPrefixNotFound ¶ added in v1.2.0
func ListResource ¶ added in v0.11.0
func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch bool, minRequestTimeout time.Duration) restful.RouteFunction
ListResource returns a function that handles retrieving a list of resources from a rest.Storage object.
func NewApisWebService ¶ added in v1.5.0
func NewApisWebService(s runtime.NegotiatedSerializer, apiPrefix string, f func(req *restful.Request) []unversioned.APIGroup) *restful.WebService
NewApisWebService returns a webservice serving the available api version under /apis.
func NewGroupWebService ¶ added in v1.5.0
func NewGroupWebService(s runtime.NegotiatedSerializer, path string, group unversioned.APIGroup) *restful.WebService
NewGroupWebService returns a webservice serving the supported versions, preferred version, and name of a group. E.g., such a web service will be registered at /apis/extensions.
func PatchResource ¶ added in v0.13.0
func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface, converter runtime.ObjectConvertor) restful.RouteFunction
PatchResource returns a function that will handle a resource patch TODO: Eventually PatchResource should just use GuaranteedUpdate and this routine should be a bit cleaner
func RootAPIHandler ¶ added in v1.1.0
func RootAPIHandler(s runtime.NegotiatedSerializer, f func(req *restful.Request) []unversioned.APIGroup) restful.RouteFunction
RootAPIHandler returns a handler which will list the provided groups and versions as available.
func SupportedResourcesHandler ¶ added in v1.1.0
func SupportedResourcesHandler(s runtime.NegotiatedSerializer, groupVersion unversioned.GroupVersion, lister APIResourceLister) restful.RouteFunction
SupportedResourcesHandler returns a handler which will list the provided resources as available.
func UpdateResource ¶ added in v0.11.0
func UpdateResource(r rest.Updater, scope RequestScope, typer runtime.ObjectTyper, admit admission.Interface) restful.RouteFunction
UpdateResource returns a function that will handle a resource update
func WriteRawJSON ¶ added in v1.5.0
func WriteRawJSON(statusCode int, object interface{}, w http.ResponseWriter)
WriteRawJSON writes a non-API object in JSON.
Types ¶
type APIGroupVersion ¶ added in v0.5.1
type APIGroupVersion struct { Storage map[string]rest.Storage Root string // GroupVersion is the external group version GroupVersion unversioned.GroupVersion // OptionsExternalVersion controls the Kubernetes APIVersion used for common objects in the apiserver // schema like api.Status, api.DeleteOptions, and api.ListOptions. Other implementors may // define a version "v1beta1" but want to use the Kubernetes "v1" internal objects. If // empty, defaults to GroupVersion. OptionsExternalVersion *unversioned.GroupVersion Mapper meta.RESTMapper // Serializer is used to determine how to convert responses from API methods into bytes to send over // the wire. Serializer runtime.NegotiatedSerializer ParameterCodec runtime.ParameterCodec Typer runtime.ObjectTyper Creater runtime.ObjectCreater Convertor runtime.ObjectConvertor Copier runtime.ObjectCopier Linker runtime.SelfLinker Admit admission.Interface Context api.RequestContextMapper MinRequestTimeout time.Duration // SubresourceGroupVersionKind contains the GroupVersionKind overrides for each subresource that is // accessible from this API group version. The GroupVersionKind is that of the external version of // the subresource. The key of this map should be the path of the subresource. The keys here should // match the keys in the Storage map above for subresources. SubresourceGroupVersionKind map[string]unversioned.GroupVersionKind // ResourceLister is an interface that knows how to list resources // for this API Group. ResourceLister APIResourceLister }
APIGroupVersion is a helper for exposing rest.Storage objects as http.Handlers via go-restful It handles URLs of the form: /${storage_key}[/${object_name}] Where 'storage_key' points to a rest.Storage object stored in storage. This object should contain all parameterization necessary for running a particular API version
func (*APIGroupVersion) InstallREST ¶ added in v0.5.1
func (g *APIGroupVersion) InstallREST(container *restful.Container) error
InstallREST registers the REST handlers (storage, watch, proxy and redirect) into a restful Container. It is expected that the provided path root prefix will serve all operations. Root MUST NOT end in a slash.
func (*APIGroupVersion) UpdateREST ¶ added in v1.1.0
func (g *APIGroupVersion) UpdateREST(container *restful.Container) error
UpdateREST registers the REST handlers for this APIGroupVersion to an existing web service in the restful Container. It will use the prefix (root/version) to find the existing web service. If a web service does not exist within the container to support the prefix this method will return an error.
type APIInstaller ¶ added in v0.11.0
type APIInstaller struct {
// contains filtered or unexported fields
}
func (*APIInstaller) Install ¶ added in v0.11.0
func (a *APIInstaller) Install(ws *restful.WebService) (apiResources []unversioned.APIResource, errors []error)
Installs handlers for API resources.
func (*APIInstaller) NewWebService ¶ added in v1.1.0
func (a *APIInstaller) NewWebService() *restful.WebService
NewWebService creates a new restful webservice with the api installer's prefix and version.
type APIResourceLister ¶ added in v1.4.0
type APIResourceLister interface {
ListAPIResources() []unversioned.APIResource
}
type ContextFunc ¶ added in v0.11.0
ContextFunc returns a Context given a request - a context must be returned
type ProxyDialerFunc ¶ added in v0.20.0
type ProxyHandler ¶
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 ¶
func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type RequestScope ¶ added in v0.14.0
type RequestScope struct { Namer ScopeNamer ContextFunc Serializer runtime.NegotiatedSerializer runtime.ParameterCodec Creater runtime.ObjectCreater Convertor runtime.ObjectConvertor Copier runtime.ObjectCopier Resource unversioned.GroupVersionResource Kind unversioned.GroupVersionKind Subresource string }
RequestScope encapsulates common fields across all RESTful handler methods.
type ScopeNamer ¶ added in v0.11.0
type ScopeNamer interface { // Namespace returns the appropriate namespace value from the request (may be empty) or an // error. Namespace(req *restful.Request) (namespace string, err error) // Name returns the name from the request, and an optional namespace value if this is a namespace // scoped call. An error is returned if the name is not available. Name(req *restful.Request) (namespace, name string, err error) // ObjectName returns the namespace and name from an object if they exist, or an error if the object // does not support names. ObjectName(obj runtime.Object) (namespace, name string, err error) // SetSelfLink sets the provided URL onto the object. The method should return nil if the object // does not support selfLinks. SetSelfLink(obj runtime.Object, url string) error // GenerateLink creates an encoded URI for a given runtime object that represents the canonical path // and query. GenerateLink(req *restful.Request, obj runtime.Object) (uri string, err error) // GenerateLink creates an encoded URI for a list that represents the canonical path and query. GenerateListLink(req *restful.Request) (uri string, err error) }
ScopeNamer handles accessing names from requests and objects
type Server ¶ added in v0.5.1
type Server struct { Addr string Port int Path string EnableHTTPS bool Validate ValidatorFn }
func (*Server) DoServerCheck ¶ added in v0.16.0
func (server *Server) DoServerCheck(prober httpprober.HTTPProber) (probe.Result, string, error)
type ServerStatus ¶
type ServerStatus struct { // +optional Component string `json:"component,omitempty"` // +optional Health string `json:"health,omitempty"` // +optional HealthCode probe.Result `json:"healthCode,omitempty"` // +optional Msg string `json:"msg,omitempty"` // +optional Err string `json:"err,omitempty"` }
type StripVersionNegotiatedSerializer ¶ added in v1.2.0
type StripVersionNegotiatedSerializer struct {
runtime.NegotiatedSerializer
}
StripVersionNegotiatedSerializer will return stripVersionEncoder when EncoderForVersion is called. See comments for stripVersionEncoder.
func (StripVersionNegotiatedSerializer) EncoderForVersion ¶ added in v1.2.0
func (n StripVersionNegotiatedSerializer) EncoderForVersion(encoder runtime.Encoder, gv runtime.GroupVersioner) runtime.Encoder
type ValidatorFn ¶ added in v0.20.0
type WatchServer ¶
type WatchServer struct {
// contains filtered or unexported fields
}
WatchServer serves a watch.Interface over a websocket or vanilla HTTP.
func (*WatchServer) HandleWS ¶
func (s *WatchServer) HandleWS(ws *websocket.Conn)
HandleWS implements a websocket handler.
func (*WatchServer) ServeHTTP ¶
func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP serves a series of encoded events via HTTP with Transfer-Encoding: chunked or over a websocket connection.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package filters contains all the http handler chain filters which _are_ api related.
|
Package filters contains all the http handler chain filters which _are_ api related. |
Package request contains everything around extracting info from a http request object.
|
Package request contains everything around extracting info from a http request object. |