k-show-secrets extended
This commit is contained in:
@@ -1,9 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/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
|
# Get the current namespace from the current kubectl context
|
||||||
NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}')
|
NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}')
|
||||||
NAMESPACE=${NAMESPACE:-default}
|
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
|
# Fetch all secret names in the current namespace
|
||||||
secrets=$(kubectl get secrets -n "$NAMESPACE" -o jsonpath="{.items[*].metadata.name}")
|
secrets=$(kubectl get secrets -n "$NAMESPACE" -o jsonpath="{.items[*].metadata.name}")
|
||||||
|
|
||||||
@@ -20,6 +27,7 @@ if [ -z "$SELECTED_SECRET" ]; then
|
|||||||
echo "🚫 No secret selected."
|
echo "🚫 No secret selected."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "🔓 Decoding secret '$SELECTED_SECRET' in namespace '$NAMESPACE'..."
|
echo "🔓 Decoding secret '$SELECTED_SECRET' in namespace '$NAMESPACE'..."
|
||||||
|
|||||||
Reference in New Issue
Block a user