Created
July 7, 2023 12:06
-
-
Save thbkrkr/babfc961178b37e3de27ee2c04374738 to your computer and use it in GitHub Desktop.
Create a Kubernetes Secret with Docker registry creds stored in docker-credential-desktop
This file contains 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
#!/bin/bash -eu | |
to_auth() { | |
jq -r '.Username,.Secret' | paste -sd ":" - | tr -d '\n' | base64 | |
} | |
main() { | |
registry="$1" | |
jq -cnM --arg auth $(docker-credential-desktop <<< "$registry" | to_auth) '{ | |
"auths": { "'"$registry"'": { "auth": $auth } } | |
}' | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment