rust-oci-client
rust-oci-client copied to clipboard
Auth is ignored in the second call to the client
trafficstars
This is what I'm trying to do:
let client = oci_client::Client::new(ClientConfig::default());
eprintln!("Trying to list with anonymous auth...");
let mut tags = client
.list_tags(&image, &RegistryAuth::Anonymous, None, None)
.await;
if let Err(
OciDistributionError::UnauthorizedError { .. }
| OciDistributionError::AuthenticationFailure(_),
) = tags
{
eprintln!("Trying to list with docker auth...");
let auth = fetch_docker_auth(&image).await?;
tags = client.list_tags(&image, &auth, None, None).await;
}
Second call fails because auth parameter is ignored.
https://github.com/oras-project/rust-oci-client/blob/a1a959791d18815c6422053c79b1e5e869c8aa78/src/client.rs#L437-L438
https://github.com/oras-project/rust-oci-client/blob/a1a959791d18815c6422053c79b1e5e869c8aa78/src/client.rs#L399-L403
The logic seems incorrect: we should either store auth or pass in parameters, but not both. And generally function parameters should not be ignored.