secretutil

package
v1.0.0-beta.33 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package secretutil contains functions to manage secrets and strategies to manage secret cache.

Index

Constants

View Source
const (
	// LabelEnvironmentName is used as key of the label for secrets that should be included in cache.
	LabelEnvironmentName = "caph.environment"
	// LabelEnvironmentValue is the value of the label for secrets that should be included in cache.
	LabelEnvironmentValue = "owned"
)
View Source
const (
	// SecretFinalizer is the finalizer for secrets.
	SecretFinalizer = infrav1.ClusterFinalizer + "/secret"
)

Variables

This section is empty.

Functions

func AddSecretSelector

func AddSecretSelector() map[client.Object]cache.ByObject

AddSecretSelector adds a selector to a cache.SelectorsByObject that filters Secrets so that only those labelled as part of the environment get cached. The input may be nil.

Types

type HCloudTokenValidationError

type HCloudTokenValidationError struct{}

HCloudTokenValidationError is returned when the HCloud token in Hetzner secret is invalid.

func (HCloudTokenValidationError) Error

type ResolveSecretRefError

type ResolveSecretRefError struct {
	Message string
}

ResolveSecretRefError is returned when the secret for a host is defined but cannot be found.

func (ResolveSecretRefError) Error

func (e ResolveSecretRefError) Error() string

type SecretManager

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

SecretManager is a type for fetching Secrets whether or not they are in the client cache, labelling so that they will be included in the client cache, and optionally setting an owner reference.

func NewSecretManager

func NewSecretManager(log logr.Logger, cacheClient client.Client, apiReader client.Reader) *SecretManager

NewSecretManager returns a new SecretManager.

func (*SecretManager) AcquireSecret

func (sm *SecretManager) AcquireSecret(ctx context.Context, key types.NamespacedName, owner client.Object, ownerIsController, addFinalizer bool) (*corev1.Secret, error)

AcquireSecret retrieves a Secret and ensures that it has a label that will ensure it is present in the cache (and that we can watch for changes), and that it has a particular owner reference. The owner reference may optionally be a controller reference.

func (*SecretManager) ObtainSecret

func (sm *SecretManager) ObtainSecret(ctx context.Context, key types.NamespacedName) (*corev1.Secret, error)

ObtainSecret retrieves a Secret and ensures that it has a label that will ensure it is present in the cache (and that we can watch for changes).

func (*SecretManager) ReleaseSecret

func (sm *SecretManager) ReleaseSecret(ctx context.Context, secret *corev1.Secret, owner client.Object) error

ReleaseSecret removes secrets manager finalizer from specified secret when needed.

Jump to

Keyboard shortcuts

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