apiutil

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 14 Imported by: 1,190

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToProtobufScheme added in v0.7.0

func AddToProtobufScheme(addToScheme func(*runtime.Scheme) error) error

AddToProtobufScheme add the given SchemeBuilder into protobufScheme, which should be additional types that do support protobuf.

func GVKForObject

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

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

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

func RESTClientForGVK(gvk schema.GroupVersionKind, isUnstructured bool, 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.

Types

type DynamicRESTMapperOption added in v0.3.0

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

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

func WithLimiter(lim *rate.Limiter) DynamicRESTMapperOption

WithLimiter sets the RESTMapper's underlying limiter to lim.

Jump to

Keyboard shortcuts

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