managedresources

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretPrefix is the prefix that can be used for secrets referenced by managed resources.
	SecretPrefix = "managedresource-"
	// LabelKeyOrigin is a key for a label on a managed resource with the value 'origin'.
	LabelKeyOrigin = "origin"
	// LabelValueGardener is a value for a label on a managed resource with the value 'gardener'.
	LabelValueGardener = "gardener"
	// LabelValueOperator is a value for an origin label on a managed resource with the value 'gardener-operator'.
	LabelValueOperator = "gardener-operator"
)

Variables

View Source
var (
	// DeleteForSeed is a function alias for deleteWithSecretNamePrefix.
	DeleteForSeed = deleteWithSecretNamePrefix
	// DeleteForShoot is a function alias for deleteWithSecretNamePrefix.
	DeleteForShoot = deleteWithSecretNamePrefix
)
View Source
var IntervalWait = 2 * time.Second

IntervalWait is the interval when waiting for managed resources.

Functions

func CheckIfManagedResourcesExist

func CheckIfManagedResourcesExist(ctx context.Context, c client.Client, class *string, excludeNames ...string) (bool, error)

CheckIfManagedResourcesExist checks if some ManagedResources of the given class still exist. If yes it returns true.

func Create

func Create(
	ctx context.Context,
	client client.Client,
	namespace, name string,
	labels map[string]string,
	secretNameWithPrefix bool,
	class string,
	data map[string][]byte,
	keepObjects *bool,
	injectedLabels map[string]string,
	forceOverwriteAnnotations *bool,
) error

Create creates a managed resource and its secret with the given name, class, key, and data in the given namespace.

func CreateForSeed

func CreateForSeed(ctx context.Context, client client.Client, namespace, name string, keepObjects bool, data map[string][]byte) error

CreateForSeed deploys a ManagedResource CR for the seed's gardener-resource-manager.

func CreateForSeedWithLabels

func CreateForSeedWithLabels(ctx context.Context, client client.Client, namespace, name string, keepObjects bool, labels map[string]string, data map[string][]byte) error

CreateForSeedWithLabels deploys a ManagedResource CR for the seed's gardener-resource-manager and allows providing additional labels.

func CreateForShoot

func CreateForShoot(ctx context.Context, client client.Client, namespace, name, origin string, keepObjects bool, data map[string][]byte) error

CreateForShoot deploys a ManagedResource CR for the shoot's gardener-resource-manager. The origin is used to identify the creator of the managed resource. Gardener acts on resources with "origin=gardener" label. External callers (extension controllers or other components) of this function should provide their own unique origin value.

func CreateForShootWithLabels

func CreateForShootWithLabels(ctx context.Context, client client.Client, namespace, name, origin string, keepObjects bool, labels map[string]string, data map[string][]byte) error

CreateForShootWithLabels deploys a ManagedResource CR for the shoot's gardener-resource-manager. The origin is used to identify the creator of the managed resource. Gardener acts on resources with "origin=gardener" label. External callers (extension controllers or other components) of this function should provide their own unique origin value. This function allows providing additional labels.

func CreateFromUnstructured

func CreateFromUnstructured(
	ctx context.Context,
	client client.Client,
	namespace, name string,
	secretNameWithPrefix bool,
	class string,
	objs []*unstructured.Unstructured,
	keepObjects bool,
	injectedLabels map[string]string,
) error

CreateFromUnstructured creates a managed resource and its secret with the given name, class, and objects in the given namespace.

func Delete

func Delete(ctx context.Context, c client.Client, namespace string, name string, secretNameWithPrefix bool) error

Delete deletes the managed resource and its secrets with the given name in the given namespace.

func GetObjects

func GetObjects(ctx context.Context, c client.Client, namespace, name string) ([]client.Object, error)

GetObjects returns the objects which belong to this managed resource.

func New

func New(client client.Client, namespace, name, class string, keepObjects *bool, labels, injectedLabels map[string]string, forceOverwriteAnnotations *bool) *builder.ManagedResource

New initiates a new ManagedResource object which can be reconciled.

func NewForSeed

func NewForSeed(c client.Client, namespace, name string, keepObjects bool) *builder.ManagedResource

NewForSeed constructs a new ManagedResource object for the seed's gardener-resource-manager.

func NewForShoot

func NewForShoot(c client.Client, namespace, name, origin string, keepObjects bool) *builder.ManagedResource

NewForShoot constructs a new ManagedResource object for the shoot's gardener-resource-manager. The origin is used to identify the creator of the managed resource. Gardener acts on resources with "origin=gardener" label. External callers (extension controllers or other components) of this function should provide their own unique origin value.

func NewSecret

func NewSecret(client client.Client, namespace, name string, data map[string][]byte, secretNameWithPrefix bool) (string, *builder.Secret)

NewSecret initiates a new immutable Secret object which can be reconciled.

func RenderChartAndCreate

func RenderChartAndCreate(ctx context.Context, namespace string, name string, secretNameWithPrefix bool, client client.Client, chartRenderer chartrenderer.Interface, chart chart.Interface, values map[string]any, imageVector imagevector.ImageVector, chartNamespace string, version string, withNoCleanupLabel bool, forceOverwriteAnnotations bool) error

RenderChartAndCreate renders a chart and creates a ManagedResource for the gardener-resource-manager out of the results.

func SetKeepObjects

func SetKeepObjects(ctx context.Context, c client.Writer, namespace, name string, keepObjects bool) error

SetKeepObjects updates the keepObjects field of the managed resource with the given name in the given namespace.

func Update

func Update(
	ctx context.Context,
	client client.Client,
	namespace, name string,
	labels map[string]string,
	secretNameWithPrefix bool,
	class string,
	data map[string][]byte,
	keepObjects *bool,
	injectedLabels map[string]string,
	forceOverwriteAnnotations *bool,
) error

Update updates a managed resource and its secret with the given name, class, key, and data in the given namespace.

func WaitUntilDeleted

func WaitUntilDeleted(ctx context.Context, client client.Client, namespace, name string) error

WaitUntilDeleted waits until the given managed resource is deleted.

func WaitUntilHealthy

func WaitUntilHealthy(ctx context.Context, client client.Client, namespace, name string) error

WaitUntilHealthy waits until the given managed resource is healthy.

func WaitUntilHealthyAndNotProgressing

func WaitUntilHealthyAndNotProgressing(ctx context.Context, client client.Client, namespace, name string) error

WaitUntilHealthyAndNotProgressing waits until the given managed resource is healthy and not progressing.

func WaitUntilListDeleted

func WaitUntilListDeleted(ctx context.Context, client client.Client, mrList *resourcesv1alpha1.ManagedResourceList, listOps ...client.ListOption) error

WaitUntilListDeleted waits until the given managed resources are deleted.

Types

type Registry

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

Registry stores objects and their serialized form. It allows to compute a map of all registered objects that can be used as part of a Secret's data which is referenced by a ManagedResource.

func NewRegistry

func NewRegistry(scheme *runtime.Scheme, codec serializer.CodecFactory, serializer *jsonserializer.Serializer) *Registry

NewRegistry returns a new registry for resources. The given scheme, codec, and serializer must know all the resource types that will later be added to the registry.

func (*Registry) Add

func (r *Registry) Add(objs ...client.Object) error

Add adds the given object to the registry. It computes a filename based on its type, namespace, and name. It serializes the object to YAML and stores both representations (object and serialization) in the registry.

func (*Registry) AddAllAndSerialize

func (r *Registry) AddAllAndSerialize(objects ...client.Object) (map[string][]byte, error)

AddAllAndSerialize calls Add() for all the given objects before calling SerializedObjects().

func (*Registry) AddSerialized

func (r *Registry) AddSerialized(filename string, serializationYAML []byte)

AddSerialized adds the provided serialized YAML for the registry. The provided filename is required and determines the internal sorting order.

func (*Registry) RegisteredObjects

func (r *Registry) RegisteredObjects() []client.Object

RegisteredObjects returns a slice of registered objects.

func (*Registry) SerializedObjects

func (r *Registry) SerializedObjects() (map[string][]byte, error)

SerializedObjects returns a map which can be used as secret data of a managed resource. The map holds a single key `data.yaml.br` with a value containing all objects, concatenated and compressed by the Brotli algorithm.

func (*Registry) String

func (r *Registry) String() string

String returns the string representation of the registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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