kube

package
v0.22.9 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrManifestNoMetadata = errors.New("Helm chart manifest has no metadata")
)
View Source
var ErrObjectNotUnstructured = errors.New("Helm object is not of type unstructured.Unstructured")

Functions

This section is empty.

Types

type ApplyOption

type ApplyOption interface {
	Apply(opts *applyOptions)
}

ApplyOption is a specific configuration used for applying changes to an object.

type Client

type Client[T any] interface {
	// Apply applies changes to an object through a Server-Side Apply
	// and takes the ownership of this object.
	// The object is created when it does not exist.
	// It errors on conflicts if force is set to false.
	Apply(ctx context.Context, obj *T, fieldManager string, opts ...ApplyOption) error
	// Update applies changes to an object.
	// The object is created when it does not exist.
	// It does not error on conflicts.
	Update(ctx context.Context, obj *T, fieldManager string, opts ...ApplyOption) error
	// Get retrieves the unstructured object from a Kubernetes cluster.
	Get(ctx context.Context, obj *T) (*T, error)
	// Delete removes the object from the Kubernetes cluster.
	Delete(ctx context.Context, obj *T) error
	// Returns the [meta.RESTMapper] associated with this client.
	RESTMapper() meta.RESTMapper
}

Client connects to a Kubernetes cluster to create, read, update and delete manifests/objects.

type DryRun

type DryRun bool

DryRun indicates that modifications should not be persisted.

func (DryRun) Apply

func (dr DryRun) Apply(opts *applyOptions)

type DynamicClient

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

DynamicClient connects to a Kubernetes cluster to create, read, update and delete unstructured manifests/objects.

func NewDynamicClient

func NewDynamicClient(config *rest.Config) (*DynamicClient, error)

NewDynamicClient constructs a new DynamicClient, which connects to a Kubernetes cluster to create, read, update and delete unstructured manifests/objects.

func (*DynamicClient) Apply

func (client *DynamicClient) Apply(
	ctx context.Context,
	obj *unstructured.Unstructured,
	fieldManager string,
	opts ...ApplyOption,
) error

Apply applies changes to an object through a Server-Side Apply and takes the ownership of this object. The object is created when it does not exist. It errors on conflicts if force is set to false.

func (*DynamicClient) Delete

func (client *DynamicClient) Delete(ctx context.Context, obj *unstructured.Unstructured) error

Delete removes the unstructured object from a Kubernetes cluster. Following fields have to be set on obj: - GVK, Namespace, Name

func (*DynamicClient) Get

Get retrieves the unstructured object from a Kubernetes cluster. Following fields have to be set on obj: - GVK, Name

func (*DynamicClient) Invalidate

func (client *DynamicClient) Invalidate() error

Invalidate resets the internally cached Discovery information and will cause the next mapping request to re-discover.

func (*DynamicClient) RESTMapper

func (client *DynamicClient) RESTMapper() meta.RESTMapper

func (*DynamicClient) Update

func (client *DynamicClient) Update(
	ctx context.Context,
	obj *unstructured.Unstructured,
	fieldManager string,
	opts ...ApplyOption,
) error

Update applies changes to an object. The object is created when it does not exist. It does not error on conflicts.

type Force

type Force bool

Force indicates that conflicts should not error.

func (Force) Apply

func (f Force) Apply(opts *applyOptions)

type HelmClient

type HelmClient struct {
	*helmKube.Client
	DynamicClient Client[unstructured.Unstructured]
	FieldManager  string
}

HelmClient is a dedicated Kubernetes client for Helm with Server-Side Apply. TODO: remove when Helm supports SSA.

func (*HelmClient) Create

func (c *HelmClient) Create(resources helmKube.ResourceList) (*helmKube.Result, error)

taken from helm.sh/helm/v3/pkg/kube and patched with SSA.

func (*HelmClient) Update

func (c *HelmClient) Update(
	original helmKube.ResourceList,
	target helmKube.ResourceList,
	force bool,
) (*helmKube.Result, error)

taken from helm.sh/helm/v3/pkg/kube and patched with SSA.

type InMemoryRESTClientGetter

type InMemoryRESTClientGetter struct {
	Cfg        *rest.Config
	RestMapper meta.RESTMapper
}

func (*InMemoryRESTClientGetter) ToDiscoveryClient

func (*InMemoryRESTClientGetter) ToRESTConfig

func (c *InMemoryRESTClientGetter) ToRESTConfig() (*rest.Config, error)

func (*InMemoryRESTClientGetter) ToRESTMapper

func (c *InMemoryRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

func (*InMemoryRESTClientGetter) ToRawKubeConfigLoader

func (c *InMemoryRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig

type ManifestMetadata

type ManifestMetadata struct {
	v1.TypeMeta
	// contains filtered or unexported fields
}

func NewManifestMetadata

func NewManifestMetadata(typeMeta v1.TypeMeta, componentID string, name string, namespace string) ManifestMetadata

func (ManifestMetadata) ComponentID

func (manifest ManifestMetadata) ComponentID() string

func (ManifestMetadata) Name

func (manifest ManifestMetadata) Name() string

func (ManifestMetadata) Namespace

func (manifest ManifestMetadata) Namespace() string

Jump to

Keyboard shortcuts

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