-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(oci): add ability to use OCI registries for storage #6017
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
base: master
Are you sure you want to change the base?
feat(oci): add ability to use OCI registries for storage #6017
Conversation
|
This PR has multiple commits, and the default merge method is: merge. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Clockwork-Muse The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @Clockwork-Muse! |
|
Hi @Clockwork-Muse. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/hold |
| } | ||
|
|
||
| const ociScheme = "oci://" | ||
| const ociLayoutScheme = "oci-layout://" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are people really using oci-layout:// for a scheme here? Does flux support that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I've seen an official "scheme" for this here. ORAS itself has CLI flags for remote vs layout directories/archives (as do some other tools), but that's not really an option in this case.
Flux doesn't appear to support OCI Layout artifacts currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is an official scheme, but...
Helm uses the uri oci:// so that lines up.
The ORAS CLI uses oci-layout to indicate the file OCI layout, so that could be confusing if people thing that is going to be read from a file.
| } | ||
|
|
||
| func TestNewRepoSpecFromUrl_Smoke(t *testing.T) { | ||
| // A set of end to end parsing tests that smoke out obvious issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just passing through here, but I think it would be better to use a web server on localhost to mock out a registry rather than ghcr. I prefer tests I can run with no Internet and that don't rely on other services being available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, absolutely.
This is why I have a (intended to be temporary) devcontainer here; one of the things it spins up (besides the golang tooling) is a container registry.
Frankly, the reason I was adding the oci-layout capability was for "simpler"/local-only testing purposes for basic behavior. I need to investigate the e2e stack more to see if I can get it to host a registry, but otherwise things are more complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever AI agent you are using could probably create a mock on a port on localhost.
| // Arbitrary, but non-infinite, timeout for running commands. | ||
| const defaultTimeout = 27 * time.Second | ||
|
|
||
| func extractDigest(n string) (string, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider using ParseReference here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into.
| return "", n, nil | ||
| } | ||
|
|
||
| func extractHost(n string) (string, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you named the returns here, it would document what the represent and you would need to declare them.
| func extractHost(n string) (string, string, error) { | |
| func extractHost(n string) (host string, rest string, err error) { |
| return "", "", errors.Errorf("failed to parse digest") | ||
| } | ||
|
|
||
| return digest, n[:digestIndex], nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a little confusing the pass back the result in reverse order here.
Also, this doesn't support valid form B oci://registry/repo@sha256:asdfasdf:v1.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix the reverse order, you're right.
I was not previously aware that form B was valid.
| return err | ||
| } | ||
|
|
||
| dst, err := oci.New(o.registry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it would be nicer to toss this code in the api/internal/oci package as a Pusher function.
|
Nice work in general. I think this would be a useful feature! |
Fixes #5134
Adds the ability to reference OCI registries.