-
-
Save aflansburg/7a9ebb10adbd4f70150840a8d3e8eb93 to your computer and use it in GitHub Desktop.
Basic jq w/ dynamic keys example with kubectl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# want to decode the output of the `kubectl get secret secname` command | |
# and specifically the `auth` value | |
# when we maybe don't know the value of the key corresponding to a container registry | |
# { | |
# "auths": { | |
# "https://index.docker.io/v1/": { | |
# "username": "smittywerbenjagermanjensen", | |
# "password": "sup3rs3cr3t", | |
# "email": "[email protected]", | |
# "auth": "c21pdHR5d2VyYmVuamFnZXJtYW5qZW5zZW46c3VwM3JzM2NyM3QK" | |
# } | |
# } | |
# } | |
kubectl get secret regcred \ | |
--output="jsonpath={.data.\.dockerconfigjson}" \ | |
| base64 --decode \ | |
| jq '.auths \ | |
| to_entries[] \ | |
| select( .key | contains("http")).value.auth' \ | |
| sed 's/"//g' \ | |
| base64 --decode | |
# > smittywerbenjagermanjensen:sup3rs3cr3t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment