Documentation
¶
Index ¶
- Constants
- Variables
- func AddSecretFinalizer(ctx context.Context, k8sClient client.Client, namespace string, ...) error
- func BuildConnectionDetailsData(in ConnectionDetailsInputs) map[string][]byte
- func CreateCredentialSecret(ctx context.Context, k8sClient client.Client, namespace string, ...) error
- func CreateKeyPairSecret(ctx context.Context, k8sClient client.Client, namespace string, ...) error
- func DeleteOwnedSecret(ctx context.Context, k8sClient client.Client, namespace string, name string, ...) (bool, error)
- func DeleteSecret(ctx context.Context, k8sClient client.Client, namespace string, ...) error
- func FetchCredentialsFromSecret(ctx context.Context, k8sClient client.Client, namespace string, ...) (username string, password string, err error)
- func FetchKeyPairFromSecret(ctx context.Context, k8sClient client.Client, namespace string, ...) (accessKeyId string, secretAccessKey string, err error)
- func ParseBytes(bytes int64) *resource.Quantity
- func ReconcileOwnedSecret(ctx context.Context, k8sClient client.Client, namespace string, name string, ...) (bool, error)
- func RemoveSecretFinalizer(ctx context.Context, k8sClient client.Client, namespace string, ...) error
- type ConnectionDetailsInputs
Constants ¶
const (
// SecretFinalizer is added to critical secrets to prevent premature deletion during namespace teardown.
SecretFinalizer = "secret.s3.bedag.ch/finalizer"
)
Variables ¶
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 ParseBytes ¶
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.