Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Created July 7, 2023 12:06
Show Gist options
  • Save thbkrkr/babfc961178b37e3de27ee2c04374738 to your computer and use it in GitHub Desktop.
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
#!/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