Documentation ¶
Overview ¶
Package catalog provides the Catalog and corresponding builders.
Index ¶
- func GVHToPath(gvh GroupVersionHook, name string) string
- func HookName(hookFunc Hook) string
- type Builder
- func (bld *Builder) AddToCatalog(catalog *Catalog) error
- func (bld *Builder) Build() (*Catalog, error)
- func (bld *Builder) Register(f func(*runtime.Scheme) error)
- func (bld *Builder) RegisterHook(hookFunc Hook, hookMeta *HookMeta) *Builder
- func (bld *Builder) RegisterOpenAPIDefinitions(getter OpenAPIDefinitionsGetter) *Builder
- type Catalog
- func (c *Catalog) AddHook(gv schema.GroupVersion, hookFunc Hook, hookMeta *HookMeta)
- func (c *Catalog) AddOpenAPIDefinitions(getter OpenAPIDefinitionsGetter)
- func (c *Catalog) Convert(in, out interface{}, context interface{}) error
- func (c *Catalog) GroupVersionHook(hookFunc Hook) (GroupVersionHook, error)
- func (c *Catalog) GroupVersionKind(obj runtime.Object) (schema.GroupVersionKind, error)
- func (c *Catalog) IsHookRegistered(gvh GroupVersionHook) bool
- func (c *Catalog) NewRequest(hook GroupVersionHook) (runtime.Object, error)
- func (c *Catalog) NewResponse(hook GroupVersionHook) (runtime.Object, error)
- func (c *Catalog) OpenAPI(version string) (*spec3.OpenAPI, error)
- func (c *Catalog) Request(hook GroupVersionHook) (schema.GroupVersionKind, error)
- func (c *Catalog) Response(hook GroupVersionHook) (schema.GroupVersionKind, error)
- func (c *Catalog) ValidateRequest(hook GroupVersionHook, obj runtime.Object) error
- func (c *Catalog) ValidateResponse(hook GroupVersionHook, obj runtime.Object) error
- type GroupHook
- type GroupVersionHook
- type Hook
- type HookMeta
- type OpenAPIDefinitionsGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GVHToPath ¶
func GVHToPath(gvh GroupVersionHook, name string) string
GVHToPath calculates the path for a given GroupVersionHook. This func is aligned with Kubernetes paths for cluster-wide resources, e.g.: /apis/storage.k8s.io/v1/storageclasses/standard. Note: name is only appended if set, e.g. the Discovery hook does not have a name.
Types ¶
type Builder ¶
type Builder struct { // GroupVersion is the GroupVersion used when registering // Hooks and OpenAPIDefinitions. GroupVersion schema.GroupVersion // contains filtered or unexported fields }
Builder builds a Catalog to allow mappings between Go types and the corresponding GroupVersionHooks, metadata and OpenAPIDefinitions.
func (*Builder) AddToCatalog ¶
AddToCatalog adds all registered Hooks with their request and response types and metadata and the OpenAPIDefinitions to the catalog.
func (*Builder) Build ¶
Build returns a new Catalog containing all registered Hooks with their request and response types and metadata and the OpenAPIDefinitions.
func (*Builder) Register ¶
Register adds a scheme setup function to the schemeBuilder. Note: This function is used by generated conversion code. If we would just expose the func from the embedded schemeBuilder directly it would not work because it is nil at that time and appending to a nil schemeBuilder doesn't propagate to our Builder.
func (*Builder) RegisterHook ¶
RegisterHook registers a Hook with its request and response types and metadata. The passed in hookFunc must have the following type: func(*RequestType,*ResponseType) The name of the func becomes the "hook" field of the GroupVersionHook.
func (*Builder) RegisterOpenAPIDefinitions ¶
func (bld *Builder) RegisterOpenAPIDefinitions(getter OpenAPIDefinitionsGetter) *Builder
RegisterOpenAPIDefinitions registers a func returning the OpenAPIDefinitions for request and response types of all Runtime Hooks of a given group version. NOTE: The OpenAPIDefinitionsGetter funcs in the API packages are generated by openapi-gen.
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog contains all information about RuntimeHooks defined in Cluster API, including mappings between RuntimeHook functions and the corresponding GroupVersionHooks, metadata and OpenAPIDefinitions.
func (*Catalog) AddHook ¶
func (c *Catalog) AddHook(gv schema.GroupVersion, hookFunc Hook, hookMeta *HookMeta)
AddHook adds a RuntimeHook function and its request and response types with the gv GroupVersion. The passed in hookFunc must have the following type: func(*RequestType,*ResponseType) The name of the func becomes the "Hook" in GroupVersionHook. GroupVersion must not have empty fields.
func (*Catalog) AddOpenAPIDefinitions ¶
func (c *Catalog) AddOpenAPIDefinitions(getter OpenAPIDefinitionsGetter)
AddOpenAPIDefinitions adds an OpenAPIDefinitionsGetter.
func (*Catalog) Convert ¶
Convert will attempt to convert in into out. Both must be pointers. Returns an error if the conversion isn't possible.
func (*Catalog) GroupVersionHook ¶
func (c *Catalog) GroupVersionHook(hookFunc Hook) (GroupVersionHook, error)
GroupVersionHook returns the GVH of the hookFunc or an error if hook is not a function or not registered.
func (*Catalog) GroupVersionKind ¶
GroupVersionKind returns the GVK of the object or an error if the object is not a pointer or not registered.
func (*Catalog) IsHookRegistered ¶
func (c *Catalog) IsHookRegistered(gvh GroupVersionHook) bool
IsHookRegistered returns true if the GroupVersionHook is registered with the catalog.
func (*Catalog) NewRequest ¶
func (c *Catalog) NewRequest(hook GroupVersionHook) (runtime.Object, error)
NewRequest returns a request object for a GroupVersionHook.
func (*Catalog) NewResponse ¶
func (c *Catalog) NewResponse(hook GroupVersionHook) (runtime.Object, error)
NewResponse returns a response object for a GroupVersionHook.
func (*Catalog) Request ¶
func (c *Catalog) Request(hook GroupVersionHook) (schema.GroupVersionKind, error)
Request returns the GroupVersionKind of the request of a GroupVersionHook.
func (*Catalog) Response ¶
func (c *Catalog) Response(hook GroupVersionHook) (schema.GroupVersionKind, error)
Response returns the GroupVersionKind of the response of a GroupVersionHook.
func (*Catalog) ValidateRequest ¶
func (c *Catalog) ValidateRequest(hook GroupVersionHook, obj runtime.Object) error
ValidateRequest validates a request object. Specifically it validates that the GVK of an object matches the GVK of the request of the Hook.
func (*Catalog) ValidateResponse ¶
func (c *Catalog) ValidateResponse(hook GroupVersionHook, obj runtime.Object) error
ValidateResponse validates a response object. Specifically it validates that the GVK of an object matches the GVK of the response of the Hook.
type GroupHook ¶
GroupHook represents Group and Hook of a GroupVersionHook. This can be used instead of GroupVersionHook when Version should not be used.
type GroupVersionHook ¶
GroupVersionHook unambiguously identifies a Hook.
func (GroupVersionHook) Empty ¶
func (gvh GroupVersionHook) Empty() bool
Empty returns true if group, version and hook are empty.
func (GroupVersionHook) GroupHook ¶
func (gvh GroupVersionHook) GroupHook() GroupHook
GroupHook returns the GroupHook of a GroupVersionHook.
func (GroupVersionHook) GroupVersion ¶
func (gvh GroupVersionHook) GroupVersion() schema.GroupVersion
GroupVersion returns the GroupVersion of a GroupVersionHook.
func (GroupVersionHook) String ¶
func (gvh GroupVersionHook) String() string
String returns a string representation of a GroupVersionHook.
type Hook ¶
type Hook interface{}
Hook is a marker interface for a RuntimeHook function. RuntimeHook functions should be defined as a: func(*RequestType, *ResponseType). The name of the func should be the name of the hook.
type HookMeta ¶
type HookMeta struct { // Summary of the hook. Summary string // Description of the hook. Description string // Tags of the hook. Tags []string // Deprecated signals if the hook is deprecated. Deprecated bool // Singleton signals if the hook can only be implemented once on a // Runtime Extension, e.g. like the Discovery hook. Singleton bool }
HookMeta holds metadata for a Hook, which is used to generate the OpenAPI definition for a Hook.
type OpenAPIDefinitionsGetter ¶
type OpenAPIDefinitionsGetter func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition
OpenAPIDefinitionsGetter defines a func which returns OpenAPI definitions for all request and response types of a GroupVersion. NOTE: The OpenAPIDefinitionsGetter funcs in the API packages are generated by openapi-gen.