dynamic

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseStatusError

func ParseStatusError(err error) error

ParseStatusError parses a Kubernetes API status from an error.

Types

type APIError

type APIError struct {
	// contains filtered or unexported fields
}

APIError is an error that wraps a Kubernetes API status. It formats the error message in a more readable format (since Kubernetes natively will only log the message, which could sometimes be simply "unknown").

func (APIError) Error

func (e APIError) Error() string

Error implements the error interface. It logs the code & reason in addition to the message, which could be simply "unknown" in some cases.

func (APIError) Status

func (e APIError) Status() metav1.Status

Status implements the apierrors.APIStatus interface.

type NamespacedClient

type NamespacedClient struct {
	// contains filtered or unexported fields
}

NamespacedClient is a dynamic client with a namespace and a discovery registry.

func NewDefaultNamespacedClient

func NewDefaultNamespacedClient(cfg config.NamespacedRESTConfig) (*NamespacedClient, error)

NewDefaultNamespacedClient creates a new namespaced dynamic client using the default discovery registry.

func NewNamespacedClient

func NewNamespacedClient(namespace string, client dynamic.Interface) *NamespacedClient

NewNamespacedClient creates a new namespaced dynamic client.

func (*NamespacedClient) Apply

Apply applies a resource on the server.

func (*NamespacedClient) Create

Create creates a resource on the server.

func (*NamespacedClient) Delete

func (c *NamespacedClient) Delete(
	ctx context.Context, desc resources.Descriptor, name string, opts metav1.DeleteOptions,
) error

Delete deletes a resource on the server.

func (*NamespacedClient) Get

Get gets a resource from the server.

func (*NamespacedClient) GetMultiple

func (c *NamespacedClient) GetMultiple(
	ctx context.Context, desc resources.Descriptor, names []string, opts metav1.GetOptions,
) ([]unstructured.Unstructured, error)

GetMultiple gets multiple resources from the server.

Kubernetes does not support getting multiple resources by name, so instead we list all resources and filter on the client side.

Ideally we'd like to use field selectors, but Kubernetes does not support set-based operators in field selectors (only in labels).

func (*NamespacedClient) List

List lists resources from the server.

When opts.Limit > 0, a single direct API call is made and the response (including its Continue token) is returned as-is. This enables callers to detect truncated results and display pagination hints.

When opts.Limit == 0, the client-go pager fetches all pages transparently.

func (*NamespacedClient) Update

Update updates a resource on the server.

type VersionedClient

type VersionedClient struct {
	*NamespacedClient
}

VersionedClient is a dynamic client that supports automatic version switching. It will automatically switch to the correct version of the resource based on the stored version.

func NewDefaultVersionedClient

func NewDefaultVersionedClient(cfg config.NamespacedRESTConfig) (*VersionedClient, error)

NewDefaultVersionedClient creates a new versioned client using the default namespaced client.

func WrapNamespacedClient

func WrapNamespacedClient(client *NamespacedClient) *VersionedClient

WrapNamespacedClient wraps a namespaced client in a versioned client.

func (*VersionedClient) Get

Get gets a resource from the server.

func (*VersionedClient) GetMultiple

func (c *VersionedClient) GetMultiple(
	ctx context.Context, desc resources.Descriptor, names []string, opts metav1.GetOptions,
) ([]unstructured.Unstructured, error)

GetMultiple gets multiple resources from the server. It will automatically re-fetch resources which need to be fetched using the stored version.

func (*VersionedClient) List

List lists resources from the server. It will automatically re-fetch resources which need to be fetched using the stored version.

Jump to

Keyboard shortcuts

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