oras-project / rust-oci-client

A Rust crate to interact with OCI registries
Apache License 2.0
96 stars 53 forks source link

feat(client): Make store_auth_if_needed public #150

Closed SuperTux88 closed 3 months ago

SuperTux88 commented 3 months ago

This allows to store auth information to the client if needed, without doing a full auth request.

I have the use-case where I might pull a blob without pulling the manifest before, as there are multiple replicas and the manifest might have been pulled by another instance already. But that means that some instances never had the auth information stored and therefore the pull of the blob fails with a 401.

I know I could all client.auth(...), but that also runs a full auth request (which even is multiple requests) every time, even if the auth info is already stored for this registry, or even when it's already authenticated for this image.

I also could keep track myself if I already authenticated for a certain registry, but that would be kinda redundant if the client already keeps track of it.

And I understand that you don't want to require to provide auth information as required parameter when pulling a blob, as if you do everything with one instance, it should already know it from pulling the manifest. So I think the best solution is just to make the store_auth_if_needed(...) public, so I can do exactly what I need to do, give the auth info to the client so it can use it if required for pulling a blob, without affecting any other use-cases and workflows.