pub fn get_credential_from_reader(
reader: impl Read,
server: &str,
) -> Result<DockerCredential, CredentialRetrievalError>Expand description
Retrieve a user’s docker credential from a given reader.
Example:
use std::{fs::File, io::BufReader};
use docker_credential::DockerCredential;
let file = File::open("config.json").expect("Unable to open config file");
let reader = BufReader::new(file);
let credential = docker_credential::get_credential_from_reader(reader, "https://index.docker.io/v1/").expect("Unable to retrieve credential");
match credential {
DockerCredential::IdentityToken(token) => println!("Identity token: {}", token),
DockerCredential::UsernamePassword(user_name, password) => println!("Username: {}, Password: {}", user_name, password),
};