controller-runtime: Index | Files

package apiutil

import ""

Package apiutil contains utilities for working with raw Kubernetes API machinery, such as creating RESTMappers and raw REST clients, and extracting the GVK of an object.


Package Files

apimachinery.go dynamicrestmapper.go

func DelayIfRateLimited Uses

func DelayIfRateLimited(err error) (time.Duration, bool)

DelayIfRateLimited returns the delay time until the next API call is allowed and true if err is of type ErrRateLimited. The zero time.Duration value and false are returned if err is not a ErrRateLimited.

func GVKForObject Uses

func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersionKind, error)

GVKForObject finds the GroupVersionKind associated with the given object, if there is only a single such GVK.

func NewDiscoveryRESTMapper Uses

func NewDiscoveryRESTMapper(c *rest.Config) (meta.RESTMapper, error)

NewDiscoveryRESTMapper constructs a new RESTMapper based on discovery information fetched by a new client with the given config.

func NewDynamicRESTMapper Uses

func NewDynamicRESTMapper(cfg *rest.Config, opts ...DynamicRESTMapperOption) (meta.RESTMapper, error)

NewDynamicRESTMapper returns a dynamic RESTMapper for cfg. The dynamic RESTMapper dynamically discovers resource types at runtime. opts configure the RESTMapper.

func RESTClientForGVK Uses

func RESTClientForGVK(gvk schema.GroupVersionKind, baseConfig *rest.Config, codecs serializer.CodecFactory) (rest.Interface, error)

RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated with the given GroupVersionKind. The REST client will be configured to use the negotiated serializer from baseConfig, if set, otherwise a default serializer will be set.

type DynamicRESTMapperOption Uses

type DynamicRESTMapperOption func(*dynamicRESTMapper) error

DynamicRESTMapperOption is a functional option on the dynamicRESTMapper

var WithLazyDiscovery DynamicRESTMapperOption = func(drm *dynamicRESTMapper) error {
    drm.lazy = true
    return nil

WithLazyDiscovery prevents the RESTMapper from discovering REST mappings until an API call is made.

func WithCustomMapper Uses

func WithCustomMapper(newMapper func() (meta.RESTMapper, error)) DynamicRESTMapperOption

WithCustomMapper supports setting a custom RESTMapper refresher instead of the default method, which uses a discovery client.

This exists mainly for testing, but can be useful if you need tighter control over how discovery is performed, which discovery endpoints are queried, etc.

func WithLimiter Uses

func WithLimiter(lim *rate.Limiter) DynamicRESTMapperOption

WithLimiter sets the RESTMapper's underlying limiter to lim.

type ErrRateLimited Uses

type ErrRateLimited struct {
    // Duration to wait until the next API call can be made.
    Delay time.Duration

ErrRateLimited is returned by a RESTMapper method if the number of API calls has exceeded a limit within a certain time period.

func (ErrRateLimited) Error Uses

func (e ErrRateLimited) Error() string

Package apiutil imports 12 packages (graph). Updated 2020-08-04. Refresh now. Tools for package owners.