k8sapi

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

WrapperTypes holds a placeholder for each type, used for generic iteration

Functions

func Apply

func Apply(c *client.Client, obj, owner client.Object, action ActionFunc) error

Apply is a functional interface for interacting with the K8s apiserver in a consistent way. Each sigs.k8s.io/controller-runtime/pkg/client.Object argument must implement the necessary Reader/Writer interfaces implemented by sigs.k8s.io/controller-runtime/pkg/client.Client.

func CreateOrUpdate

func CreateOrUpdate(c client.Client, obj client.Object) (string, error)

CreateOrUpdate is an Action that applies a resource in the K8s apiserver.

func Delete added in v0.10.0

func Delete(c *client.Client, obj gitops.K8sObjectRef) error

func DeleteAll added in v0.10.0

func DeleteAll(c *client.Client, deleted []gitops.K8sObjectRef)

func Get added in v0.10.0

func Get(c client.Client, obj client.Object) (string, error)

Get is an Action checks if a resource exists in the K8s apiserver.

func GetOrCreate

func GetOrCreate(c client.Client, obj client.Object) (string, error)

GetOrCreate is an Action that ensures a resource exists in the K8s apiserver.

Types

type AbstractWorkload added in v0.10.0

type AbstractWorkload interface {
	GetObject() client.Object
	GetName() string
	GetNamespace() string
	GetPodTemplateSpec() corev1.PodTemplateSpec
	SetPodTemplateSpec(corev1.PodTemplateSpec)
	GetDeletionTimestamp() *metav1.Time
	GetAnnotations() map[string]string
	SetAnnotations(map[string]string)
	ListAll(c *client.Client, opts []client.ListOption) ([]AbstractWorkload, error)
	Apply(c *client.Client) error
}

AbstractWorkload is an interface with functionality common to Deployments and StatefulSets. It's used for generic manipulation of a workload.

type ActionFunc

type ActionFunc func(client.Client, client.Object) (string, error)

ActionFunc is a type of function that makes a sequence of API calls to a K8s apiserver. If any API call fails, the ActionFunc should return a string describing the failed call, plus the error returned by the sigs.k8s.io/controller-runtime/pkg/client.Client. Otherwise, the ActionFunc should return a string describing its successful result, and a nil error.

func MkPatchAction

func MkPatchAction(patch func(client.Object) client.Object) ActionFunc

MkPatchAction returns an Action that applies the patch specified when called.

type DeploymentWrapper added in v0.10.0

type DeploymentWrapper struct {
	*appsv1.Deployment
}

DeploymentWrapper implements AbstractWorkload for Deployments

func (*DeploymentWrapper) Apply added in v0.10.0

func (d *DeploymentWrapper) Apply(c *client.Client) error

func (*DeploymentWrapper) GetName added in v0.10.0

func (d *DeploymentWrapper) GetName() string

func (*DeploymentWrapper) GetNamespace added in v0.10.0

func (d *DeploymentWrapper) GetNamespace() string

func (*DeploymentWrapper) GetObject added in v0.10.0

func (d *DeploymentWrapper) GetObject() client.Object

func (*DeploymentWrapper) GetPodTemplateSpec added in v0.10.0

func (d *DeploymentWrapper) GetPodTemplateSpec() corev1.PodTemplateSpec

func (*DeploymentWrapper) ListAll added in v0.10.0

func (d *DeploymentWrapper) ListAll(c *client.Client, opts []client.ListOption) (workloads []AbstractWorkload, err error)

func (*DeploymentWrapper) SetPodTemplateSpec added in v0.10.0

func (d *DeploymentWrapper) SetPodTemplateSpec(template corev1.PodTemplateSpec)

type StatefulSetWrapper added in v0.10.0

type StatefulSetWrapper struct {
	*appsv1.StatefulSet
}

StatefulSetWrapper implements AbstractWorkload for StatefulSets

func (*StatefulSetWrapper) Apply added in v0.10.0

func (s *StatefulSetWrapper) Apply(c *client.Client) error

func (*StatefulSetWrapper) GetName added in v0.10.0

func (s *StatefulSetWrapper) GetName() string

func (*StatefulSetWrapper) GetNamespace added in v0.10.0

func (d *StatefulSetWrapper) GetNamespace() string

func (*StatefulSetWrapper) GetObject added in v0.10.0

func (d *StatefulSetWrapper) GetObject() client.Object

func (*StatefulSetWrapper) GetPodTemplateSpec added in v0.10.0

func (s *StatefulSetWrapper) GetPodTemplateSpec() corev1.PodTemplateSpec

func (*StatefulSetWrapper) ListAll added in v0.10.0

func (s *StatefulSetWrapper) ListAll(c *client.Client, opts []client.ListOption) (workloads []AbstractWorkload, err error)

func (*StatefulSetWrapper) SetPodTemplateSpec added in v0.10.0

func (s *StatefulSetWrapper) SetPodTemplateSpec(template corev1.PodTemplateSpec)

Jump to

Keyboard shortcuts

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