k-show-secrets extended

This commit is contained in:
2025-11-17 08:34:42 +01:00
parent a910fd29d9
commit 6ccfe53077

View File

@@ -1,9 +1,16 @@
#!/bin/bash
# k-show-secret: Display Kubernetes secrets interactively or by name
# Usage: k-show-secret [secret-name] (uses fzf if no name is provided)
# Get the current namespace from the current kubectl context
NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}')
NAMESPACE=${NAMESPACE:-default}
# If a secret name is passed as argument, use it; otherwise use fzf
if [ -n "$1" ]; then
SELECTED_SECRET="$1"
else
# Fetch all secret names in the current namespace
secrets=$(kubectl get secrets -n "$NAMESPACE" -o jsonpath="{.items[*].metadata.name}")
@@ -20,6 +27,7 @@ if [ -z "$SELECTED_SECRET" ]; then
echo "🚫 No secret selected."
exit 1
fi
fi
echo
echo "🔓 Decoding secret '$SELECTED_SECRET' in namespace '$NAMESPACE'..."