client

package
v0.0.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const KformSystemNamespace = `
apiVersion: v1
kind: Namespace
metadata:
  name: kform-system
`

Variables

This section is empty.

Functions

func InvInfoToConfigMap

func InvInfoToConfigMap(inv Info) *unstructured.Unstructured

Types

type Client

type Client interface {
	// GetClusterInventory returns the inventory, which consists of the providers with their
	// resp. configs and the packages with their respective objRefs;
	// or an error if one occurred.
	GetClusterInventory(ctx context.Context, inv Info) (*invv1alpha1.Inventory, error)
	// GetClusterInventoryInfo returns the cluster inventory object.
	GetClusterInventoryInfo(ctx context.Context, inv Info) (*unstructured.Unstructured, error)

	Apply(ctx context.Context, inv *unstructured.Unstructured) error

	Delete(ctx context.Context, inv *unstructured.Unstructured) error
}

Client expresses an interface for interacting with objects which store references to objects (inventory objects).

type ClientFactory

type ClientFactory interface {
	NewClient(factory util.Factory) (Client, error)
}

ClientFactory is a factory that constructs new Client instances.

type ClusterClient

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

ClusterClient is a implementation of the Client interface.

func NewClient

func NewClient(
	factory util.Factory,
	invToStorageFunc ToStorageFunc,
	invToUnstructuredFunc ToUnstructuredFunc,
	statusPolicy policy.StatusPolicy) (*ClusterClient, error)

NewClient returns a concrete implementation of the Client interface or an error.

func (*ClusterClient) Apply

getMapping returns the RESTMapping for the provided resource.

func (*ClusterClient) Delete

getMapping returns the RESTMapping for the provided resource.

func (*ClusterClient) GetClusterInventory

func (r *ClusterClient) GetClusterInventory(ctx context.Context, inv Info) (*invv1alpha1.Inventory, error)

func (*ClusterClient) GetClusterInventoryInfo

func (r *ClusterClient) GetClusterInventoryInfo(ctx context.Context, inv Info) (*unstructured.Unstructured, error)

type ClusterClientFactory

type ClusterClientFactory struct {
	StatusPolicy policy.StatusPolicy
}

ClusterClientFactory is a factory that creates instances of ClusterClient inventory client.

func (ClusterClientFactory) NewClient

func (r ClusterClientFactory) NewClient(factory util.Factory) (Client, error)

type ConfigMap

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

ConfigMap wraps a ConfigMap resource and implements the Info/Storage interface.

func (*ConfigMap) GetObject

func (r *ConfigMap) GetObject(ctx context.Context, providers map[string]string, newActuatedResources store.Storer[store.Storer[data.BlockData]]) (*unstructured.Unstructured, error)

GetObject returns the wrapped object (ConfigMap) as a resource.Info or an error if one occurs.

func (*ConfigMap) ID

func (r *ConfigMap) ID() string

func (*ConfigMap) Load

Load is an Inventory interface function returning the set of object metadata per provider from the wrapped ConfigMap, or an error.

func (*ConfigMap) Name

func (r *ConfigMap) Name() string

func (*ConfigMap) Namespace

func (r *ConfigMap) Namespace() string

func (*ConfigMap) NamespacedName

func (r *ConfigMap) NamespacedName() string

type Info

type Info interface {
	// Namespace of the inventory object.
	// It should be the value of the field .metadata.namespace.
	Namespace() string

	// Name of the inventory object.
	// It should be the value of the field .metadata.name.
	Name() string

	// Combines Namespace and Name as a string
	NamespacedName() string

	// ID of the inventory object.
	ID() string
}

Info provides the methods to lookup the inventory object

func WrapInventoryInfoObj

func WrapInventoryInfoObj(inv *unstructured.Unstructured) Info

WrapInventoryInfoObj takes a passed ConfigMap, wraps it with the ConfigMap and upcasts the wrapper as an the Info interface.

type Storage

type Storage interface {
	// GetObject returns the object that stores the inventory
	GetObject(ctx context.Context, providers map[string]string, newActuatedResources store.Storer[store.Storer[data.BlockData]]) (*unstructured.Unstructured, error)
	// Load retrieves the set of object metadata from the inventory object
	Load(ctx context.Context) (*invv1alpha1.Inventory, error)
}

Storage describes methods necessary for an object which can persist the object metadata for pruning and other group operations.

func WrapInventoryObj

func WrapInventoryObj(inv *unstructured.Unstructured) Storage

WrapInventoryObj takes a passed ConfigMap, wraps it with the ConfigMap and upcasts the wrapper as an the Inventory interface.

type ToStorageFunc

type ToStorageFunc func(*unstructured.Unstructured) Storage

ToStorageFunc creates the object which implements the Storage interface from the passed inv object.

type ToUnstructuredFunc

type ToUnstructuredFunc func(Info) *unstructured.Unstructured

ToUnstructuredFunc returns the unstructured object for the given Info.

Jump to

Keyboard shortcuts

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