Documentation ¶
Overview ¶
Package secretutil contains functions to manage secrets and strategies to manage secret cache.
Index ¶
- Constants
- func AddSecretSelector() map[client.Object]cache.ByObject
- type HCloudTokenValidationError
- type ResolveSecretRefError
- type SecretManager
- func (sm *SecretManager) AcquireSecret(ctx context.Context, key types.NamespacedName, owner client.Object, ...) (*corev1.Secret, error)
- func (sm *SecretManager) ObtainSecret(ctx context.Context, key types.NamespacedName) (*corev1.Secret, error)
- func (sm *SecretManager) ReleaseSecret(ctx context.Context, secret *corev1.Secret, owner client.Object) error
Constants ¶
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" )
const ( // SecretFinalizer is the finalizer for secrets. SecretFinalizer = infrav1.ClusterFinalizer + "/secret" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HCloudTokenValidationError ¶
type HCloudTokenValidationError struct{}
HCloudTokenValidationError is returned when the HCloud token in Hetzner secret is invalid.
func (HCloudTokenValidationError) Error ¶
func (e HCloudTokenValidationError) Error() string
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.