Skip to content

Instantly share code, notes, and snippets.

@BobyMCbobs
Created July 25, 2023 07:10
Show Gist options
  • Save BobyMCbobs/329d57264f0ef1d217e4b2382e9bf364 to your computer and use it in GitHub Desktop.
Save BobyMCbobs/329d57264f0ef1d217e4b2382e9bf364 to your computer and use it in GitHub Desktop.
A small bash script to tidly base64 decode secrets
#!/bin/bash
POSITIONAL_ARGS=()
NAMESPACE=default
while [[ $# -gt 0 ]]; do
case $1 in
-n|--namespace)
NAMESPACE="$2"
shift # past argument
shift # past value
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}"
SECRET="$1"
kubectl -n "${NAMESPACE:-default}" get secrets "$SECRET" -o=go-template='{{ range $key, $value := .data }}{{ $key }}={{ base64decode $value }}{{ "\n" }}{{ end }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment