solo-io / wasm

Web Assembly tools and SDKs for extending cloud-native infrastructure
Apache License 2.0
305 stars 39 forks source link

Support `--password-stdin`, similar to other OCI tools #241

Open zortness opened 3 years ago

zortness commented 3 years ago

When using repositories like AWS ECR, the authentication expires quite rapidly and the generated passwords tend to be quite long. Other extant OCI style tools, such as the docker utility, support taking in a password from stdin, allowing the developer to skip a step of making a temporary file or copying the password to the clipboard.

Using --password-stdin will match up with the docker and podman utilities, and coincide well with AWS's instructions on how to use their ECR service.

Before:

aws ecr get-login-password --region us-west-2 > .ecr_pw
<cat or copy really_long_pw to clipboard>
wasme login -s <aws_ecr_url> -u AWS -p <paste really_long_pw>

After:

aws ecr get-login-password --region us-west-2 | wasme login -s <aws_ecr_url> -u AWS --password-stdin
zortness commented 3 years ago

Consequently because wasme is using the oras library, the temporary workaround I have here is to log in via the oras command line tool before attempting wasme push or wasme pull commands.

EG:

aws ecr get-login-password --region us-west-2 | oras login -u AWS --password-stdin <aws_ecr_url>
wasme push <aws_ecr_url>/image:<version>

This works because oras writes out login information to ~/.docker/config.json, which the library also reads from by default.