generic

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsWrongType

func IsWrongType(err error) bool

IsWrongType asserts wrongTypeError.

Types

type Config

type Config struct {
	// ClientFunc is a function that takes a namespace and returns a Kubernetes
	// client for resources of the specific kind in that namespace.
	ClientFunc func(string) Interface

	// Logger to use for logging.
	Logger micrologger.Logger

	// Name of the resource handler.
	// Note this is not the same thing as name of the resource.
	Name string

	// GetObjectMeta is a function that takes a resource object, casts it to
	// appropriate type and returns the metadata of that object, i.e. its
	// metav1.ObjectMeta part (name, namespace, labels, annotations, etc.).
	GetObjectMeta func(interface{}) (metav1.ObjectMeta, error)

	// GetDesiredObject is a function that takes a resource object and returns the
	// object populated with the desired state.
	GetDesiredObject func(interface{}) (metav1.Object, error)

	// HasChangedFunc is a function that takes two copies of an object - first
	// with existing state in the cluster and second with the desired state for
	// the given resource and returns true if there is a difference between
	// them and therefore state needs to be reconciled to match the desired.
	HasChangedFunc func(metav1.Object, metav1.Object) bool
}

Config contains dependencies for Resource struct.

type Interface

type Interface interface {
	Create(ctx context.Context, object metav1.Object, options metav1.CreateOptions) (metav1.Object, error)
	Update(ctx context.Context, object metav1.Object, options metav1.UpdateOptions) (metav1.Object, error)
	Get(ctx context.Context, name string, options metav1.GetOptions) (metav1.Object, error)
	Delete(ctx context.Context, name string, options *metav1.DeleteOptions) error
}

type Resource

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

func New

func New(config Config) (*Resource, error)

func (*Resource) EnsureCreated

func (r *Resource) EnsureCreated(ctx context.Context, obj interface{}) error

func (*Resource) EnsureDeleted

func (r *Resource) EnsureDeleted(ctx context.Context, obj interface{}) error

func (*Resource) Name

func (r *Resource) Name() string

Jump to

Keyboard shortcuts

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