kube

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretFinalizer is added to critical secrets to prevent premature deletion during namespace teardown.
	SecretFinalizer = "secret.s3.bedag.ch/finalizer"
)

Variables

View Source
var ErrSecretNotOwned = errors.New("secret exists and is controlled by a different owner")

ErrSecretNotOwned is returned by ReconcileOwnedSecret when the target Secret already exists and is controlled by a different owner.

Functions

func AddSecretFinalizer

func AddSecretFinalizer(ctx context.Context, k8sClient client.Client, namespace string, secretName string) error

AddSecretFinalizer adds the protective finalizer to a secret to prevent premature deletion during namespace teardown.

func BuildConnectionDetailsData

func BuildConnectionDetailsData(in ConnectionDetailsInputs) map[string][]byte

BuildConnectionDetailsData renders the standard connection-details Secret payload using the AWS env-var conventions.

func CreateCredentialSecret

func CreateCredentialSecret(ctx context.Context, k8sClient client.Client, namespace string, secretName string, username string, password string, owner metav1.Object, ownerKind string) error

creates a secret with keys "username" and "password" in the specified namespace.

func CreateKeyPairSecret

func CreateKeyPairSecret(ctx context.Context, k8sClient client.Client, namespace string, secretName string, accessKeyId string, secretAccessKey string, owner metav1.Object, ownerKind string) error

creates a secret with keys "accessKeyId" and "secretAccessKey" in the specified namespace.

func DeleteOwnedSecret

func DeleteOwnedSecret(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
	owner metav1.Object,
) (bool, error)

DeleteOwnedSecret deletes a Secret by name. Callers are expected to only call this for Secrets they previously created (tracked via status). Returns (deleted, err): deleted=true when a delete request was issued; err=nil with deleted=false means the Secret did not exist (treated as a no-op so removal is idempotent).

func DeleteSecret

func DeleteSecret(ctx context.Context, k8sClient client.Client, namespace string, secretName string) error

DeleteSecret deletes a secret from the specified namespace.

func FetchCredentialsFromSecret

func FetchCredentialsFromSecret(ctx context.Context, k8sClient client.Client, namespace string, secretName string) (username string, password string, err error)

FetchCredentialsFromSecret fetches a Secret and returns the credentials as strings. assumes that the keys are always "username" and "password".

func FetchKeyPairFromSecret

func FetchKeyPairFromSecret(ctx context.Context, k8sClient client.Client, namespace string, secretName string) (accessKeyId string, secretAccessKey string, err error)

func ParseBytes

func ParseBytes(bytes int64) *resource.Quantity

ParseBytes parses an int64 byte value into a string like "1Gi".

func ReconcileOwnedSecret

func ReconcileOwnedSecret(
	ctx context.Context,
	k8sClient client.Client,
	namespace string,
	name string,
	data map[string][]byte,
	owner client.Object,
) (bool, error)

ReconcileOwnedSecret creates or updates a connection-details Secret owned by `owner`. Standard labels (managed-by, part-of, instance, secret-type) are derived from the owner's GVK and name. Secrets with no controller reference are adopted (the owner ref is re-established) so that accidental removal of the OwnerReference by a user heals on the next reconcile. If the Secret already exists and is controlled by a different owner, it returns ErrSecretNotOwned without modifying the existing Secret.

Returns true if the Secret was created or updated; false when no change was needed.

func RemoveSecretFinalizer

func RemoveSecretFinalizer(ctx context.Context, k8sClient client.Client, namespace string, secretName string) error

RemoveSecretFinalizer removes the protective finalizer from a secret to allow deletion.

Types

type ConnectionDetailsInputs

type ConnectionDetailsInputs struct {
	AccessKeyID     string
	SecretAccessKey string
	EndpointURL     string
	Region          string
	BucketName      string
}

ConnectionDetailsInputs holds the data points needed to render a connection-details Secret.

Jump to

Keyboard shortcuts

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