package apiutil
import "sigs.k8s.io/controller-runtime/pkg/client/apiutil"
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 ¶
- func AddToProtobufScheme(addToScheme func(*runtime.Scheme) error) error
- func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersionKind, error)
- func IsGVKNamespaced(gvk schema.GroupVersionKind, restmapper meta.RESTMapper) (bool, error)
- func IsObjectNamespaced(obj runtime.Object, scheme *runtime.Scheme, restmapper meta.RESTMapper) (bool, error)
- func NewDynamicRESTMapper(cfg *rest.Config, httpClient *http.Client) (meta.RESTMapper, error)
- func RESTClientForGVK(gvk schema.GroupVersionKind, isUnstructured bool, baseConfig *rest.Config, codecs serializer.CodecFactory, httpClient *http.Client) (rest.Interface, error)
- type ErrResourceDiscoveryFailed
Functions ¶
func AddToProtobufScheme ¶
AddToProtobufScheme add the given SchemeBuilder into protobufScheme, which should be additional types that do support protobuf.
func GVKForObject ¶
GVKForObject finds the GroupVersionKind associated with the given object, if there is only a single such GVK.
func IsGVKNamespaced ¶
func IsGVKNamespaced(gvk schema.GroupVersionKind, restmapper meta.RESTMapper) (bool, error)
IsGVKNamespaced returns true if the object having the provided GVK is namespace scoped.
func IsObjectNamespaced ¶
func IsObjectNamespaced(obj runtime.Object, scheme *runtime.Scheme, restmapper meta.RESTMapper) (bool, error)
IsObjectNamespaced returns true if the object is namespace scoped. For unstructured objects the gvk is found from the object itself.
func NewDynamicRESTMapper ¶
NewDynamicRESTMapper returns a dynamic RESTMapper for cfg. The dynamic RESTMapper dynamically discovers resource types at runtime.
func RESTClientForGVK ¶
func RESTClientForGVK(gvk schema.GroupVersionKind, isUnstructured bool, baseConfig *rest.Config, codecs serializer.CodecFactory, httpClient *http.Client) (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 ErrResourceDiscoveryFailed ¶
type ErrResourceDiscoveryFailed map[schema.GroupVersion]error
ErrResourceDiscoveryFailed is returned if the RESTMapper cannot discover supported resources for some GroupVersions. It wraps the errors encountered, except "NotFound" errors are replaced with meta.NoResourceMatchError, for backwards compatibility with code that uses meta.IsNoMatchError() to check for unsupported APIs.
func (*ErrResourceDiscoveryFailed) Error ¶
func (e *ErrResourceDiscoveryFailed) Error() string
Error implements the error interface.
func (*ErrResourceDiscoveryFailed) Unwrap ¶
func (e *ErrResourceDiscoveryFailed) Unwrap() []error
Source Files ¶
apimachinery.go errors.go restmapper.go
- Version
- v0.21.0 (latest)
- Published
- May 20, 2025
- Platform
- linux/amd64
- Imports
- 19 packages
- Last checked
- 25 minutes ago –
Tools for package owners.