ezkube

package
v0.22.11 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 178

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterRefsMatch added in v0.7.17

func ClusterRefsMatch(ref1, ref2 ClusterResourceId) bool

func MakeClientObjectKey added in v0.7.17

func MakeClientObjectKey(ref ResourceId) client.ObjectKey

func MakeClusterObjectRef

func MakeClusterObjectRef(resource ClusterResourceId) *v1.ClusterObjectRef

func MakeObjectRef

func MakeObjectRef(resource ResourceId) *v1.ObjectRef

func NewEnsurer

func NewEnsurer(restClient RestClient) *ensurer

Instantiate an Ensurer from a RestClient

func NewRestClient

func NewRestClient(mgr manager.Manager) *restClient

NewRestClient creates the root REST client used to interact with Kubernetes. Wraps the controller-runtime client.Client. TODO: option to skip cache reads

func ParseGroupVersionKindString added in v0.7.17

func ParseGroupVersionKindString(gvk string) (schema.GroupVersionKind, error)

parses a string returned by a gvk.String() back into a gvk

func RefsMatch added in v0.7.17

func RefsMatch(ref1, ref2 ResourceId) bool

func UpdateResourceVersion

func UpdateResourceVersion(c RestClient, ctx context.Context, obj Object) error

Uses the provided client to update the resource of the object by retrieving it from the server

Types

type ClusterResourceId

type ClusterResourceId interface {
	GetName() string
	GetNamespace() string
	GetClusterName() string
}

ResourceId represents a global identifier for a k8s resource.

type Ctl

type Ctl interface {
	Ensurer
}

Ctl is a Control object for interacting with the Kubernetes API. Its meant as a generic, high-level abstraction over kubernetes client-go, similar to an in-process kubectl

type Ensurer

type Ensurer interface {
	RestClient
	// optional reconcile funcs can be passed which determine how
	// a child object should be reconciled with the existing object
	// when it already exists in the cluster
	Ensure(ctx context.Context, parent Object, child Object, reconcileFuncs ...ReconcileFunc) error
}

an Ensurer "ensures" that the given object will be created/applied to the cluster the object is applied after a resource version conflict. Warning: this can lead to race conditions if it is called asynchronously for the same resource. The ensured resource will have its controller reference set to the parent resource

type List

type List interface {
	runtime.Object
	v1.ListInterface
}

the EzKube Object is a wrapper for a kubernetes List object

type ManagerGetter

type ManagerGetter interface {
	Manager() manager.Manager
}

Our manager returns a manager.Manager

type Object

type Object interface {
	runtime.Object
	v1.Object
}

the EzKube Object is a wrapper for a kubernetes runtime.Object which contains Kubernetes metadata

type ReconcileFunc

type ReconcileFunc func(old Object, new Object) (*Object, error)

ReconcileFuncs are used to dynamically update existing objects on calls to Update and Ensure. ReconcileFuncs perform a comparison of the the existing object with the desired object prior to writing to kube storage.

The returned object will be applied to the cluster If a nil, nil is returned, the write will be skipped

type ResourceId

type ResourceId interface {
	GetName() string
	GetNamespace() string
}

ResourceId represents a global identifier for a k8s resource.

type RestClient

type RestClient interface {
	ManagerGetter

	// the Object passed will be updated to match the server version.
	// only key (namespace/name) is required
	Get(ctx context.Context, obj Object) error

	// Object passed will be updated to match the server version.
	// Object should be a List object
	// 	example:
	//
	// 	Client.List(ctx,
	// 		client.InNamespace("my-namespace",
	// 		client.MatchingLabels{"app": "petstore"})
	List(ctx context.Context, obj List, options ...client.ListOption) error

	// create the object passed
	Create(ctx context.Context, obj Object) error

	// update the object passed. does not update object subresources such as status.
	//
	// optional reconcile funcs can be passed which determine how
	// a child object should be reconciled with the existing object
	// when it already exists in the cluster
	Update(ctx context.Context, obj Object, reconcileFuncs ...ReconcileFunc) error

	// update the status of the object passed.
	UpdateStatus(ctx context.Context, obj Object) error

	// delete the object. only key (namespace/name) is required
	Delete(ctx context.Context, obj Object) error
}

RestClient is a wrapper for the dynamic controller-runtime client.Client

Directories

Path Synopsis
Package mock_ezkube is a generated GoMock package.
Package mock_ezkube is a generated GoMock package.

Jump to

Keyboard shortcuts

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