Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use ORAS credentials #917

Merged
merged 1 commit into from Feb 16, 2024

Conversation

zregvart
Copy link
Contributor

The OCI go-getter support implemented in Conftest uses github.com/cpuguy83/dockercfg. With ORAS v2.4.0 the credentials support[1] was integrated in the oras-go. This makes for a good opportunity to switch to using that instead. In addition to using the supported credentials implementation this allows the use of Docker native credential helpers[2].

This implementation is also a bit more correct, as it avoids using the global default HTTP client, so mutations of it, e.g. when setting the user-agent, do not cause race issues.

[1] https://github.com/oras-project/oras-credentials-go
[2] https://docs.docker.com/engine/reference/commandline/login/#credential-helpers

Copy link
Member

@jalseth jalseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, this makes sense to me. One minor nit.

internal/registry/client_test.go Outdated Show resolved Hide resolved
The OCI go-getter support implemented in Conftest uses
github.com/cpuguy83/dockercfg. With ORAS v2.4.0 the credentials
support[1] was integrated in the oras-go. This makes for a good
opportunity to switch to using that instead. In addition to using the
supported credentials implementation this allows the use of Docker
native credential helpers[2].

This implementation is also a bit more correct, as it avoids using the
global default HTTP client, so mutations of it, e.g. when setting the
user-agent, do not cause race issues.

[1] https://github.com/oras-project/oras-credentials-go
[2] https://docs.docker.com/engine/reference/commandline/login/#credential-helpers

Signed-off-by: Zoran Regvart <zoran@regvart.com>
Copy link
Member

@jalseth jalseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@jalseth jalseth merged commit bbee303 into open-policy-agent:master Feb 16, 2024
7 checks passed
@zregvart zregvart deleted the pr/oras-credentials branch February 16, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants