hub-tool
hub-tool copied to clipboard
Add the ability to pass token/password to hub-tool using CLI switches or environment vars
Description
Add the ability to pass token/password to hub-tool using CLI switches or environment vars. Other CLI's like docker
do this for comparison.
$ hub-tool/hub-tool login <user> --password-stdin <<<$(echo "password")
Do something similar with LastPass's CLI
$ docker login -u $(lpass show --username 'dockeruser') --password-stdin <<<$(lpass show --password 'dockerpass')
References
- https://docs.docker.com/engine/reference/commandline/login/
I tried this (very hacky) workaround (I'm using ubuntu-latest
on my GitHub Actions runner):
/usr/bin/expect <(cat << EOF
spawn /tmp/hub-tool login ${{ secrets.DOCKERHUB_USERNAME }}
expect "\033\[0;34mPassword: \033\[0m"
send "${{ secrets.DOCKERHUB_TOKEN }}\n"
interact
EOF
)
But it's failing, most likely due to "Password: " being printed with colors. I tested locally and this WORKS on my machine even without the ANSI colors codes, but not on GitHub Actions' runner. :-(
What I ended up doing, for now (but sucessfully): built the ~/.docker/config.json
by hand. For the JWT token, I get it with a cURL request directly to the API. 🤷🏻♂️
Then I can use hub-tool
, as it's much easier than talking to the API directly.
I have a patch for this in https://github.com/docker/hub-tool/pull/198 which enables providing the Docker Hub password using the DOCKER_PASSWORD
environment variable.