WILT: LastPass integration for shell scripts

Using Docker is great. I can keep multiple environments on hand for when I need them, like having a dedicated behave container I can keep up to date with all dependencies without worring about clashes with other tools. I can call this container whenever I want with:

1docker run -i --rm \
2    -v "$(pwd)":/uat \
3    -t pytest behave \
4    --define baseurl="https://testurl.dev" \
5    --define admin_user="admin" \
6    --define admin_password="password" \
7    --junit --capture --capture-stderr /uat

It's great! Except that my test username and password is stored in my zsh history. Or I bake it into the Docker container. That's less than ideal. However, using the password manager LastPass I can download a command line tool. So I can use a quick sub-command in the docker call to get the credentials from LastPass. If I haven't logged in to the LastPass shell recently it prompts me - so it's not a permanent store either.

1docker run -i --rm \
2    -v "$(pwd)":/uat \
3    -t pytest behave \
4    --define baseurl="https://testurl.dev" \
5    --define admin_user="$(lpass show --field username_field lastpass_secret_id)" \
6    --define admin_password="$(lpass show --field password_field lastpass_secret_id)" \
7    --junit --capture --capture-stderr /uat

Feels quite a bit safer this way.