Open edwardgeorge opened 4 years ago
@steveeJ this PR is perhaps a little more controversial with using the intermediate struct. I favoured this initially as it kept it as part of deserialisation and left the auth logic untouched and ensured that the BearerAuth
datatype has a non-optional token field.
An alternative approach is implemented in this branch here: https://github.com/camallo/dkregistry-rs/compare/master...edwardgeorge:access_token_getter
If you prefer that method I can overwrite the commit in this PR with the commit from this other branch? It would be good to get this support in to allow use of the library with, eg, Azure CR which i am presently using this lib against.
Adds support for more container registries, eg: Azure (which is what I am attempting to use, requiring this change).
According to the docker specs:
Serde doesn't support deriving a
Deserialize
instance with required fields that may appear under multiple names, so rather than manually implement the complexDeserialize
trait here we use an intermediate struct with a simplerTryFrom
implementation. No changes to the auth handling logic itself.