A Rust library for reading a user's Docker credentials from config.
Parses a docker config.json
either at the loction specified by the
$DOCKER_CONFIG
environment variable or in $HOME/.docker
. If credential
helpers or a credential store is configured these will be contacted to retrieve
the requested credential.
Add the following to your cargo.toml
:
toml
[dependencies]
docker_credential = "1.0"
Then invoke from within your along the lines of:
```rust use dockercredential; use dockercredential::DockerCredential;
let credential = dockercredential::getcredential("https://index.docker.io/v1/").expect("Unable to retrieve credential");
match credential { DockerCredential::IdentityToken(token) => println!("Identity token: {}", token), DockerCredential::UsernamePassword(username, password) => println!("Username: {}, Password: {}", username, password), };
```