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

Registry Interface #81

Merged
merged 3 commits into from
Dec 6, 2021
Merged

Conversation

shizhMSFT
Copy link
Contributor

Resolves #58

Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
registry/reference.go Outdated Show resolved Hide resolved
Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

@deitch
Copy link
Contributor

deitch commented Dec 5, 2021

@shizhMSFT I am trying to wrap my head around it. I have a few questions, although I think I get it.

  • registry as top-level: Why is the registry/ package at the top-level and not part of content? I think you are stating that there are two (maybe more) high-level interfaces: Copy() which copies things from Target A to Target B; and registry.Registry which provides for interactions with a registry. Of course, I can use a registry.Registry to get a registry.Repository, which satisfies a Target, which is usable with Copy(). Is that it? If so, I think having the docs state explicitly what the key to-level entry points to oras are. I was thinking entirely in Copy() terms until I got the above, and then it all seemed to make sense (if I got it right, that is).
  • content and Target. I understand why a registry.Repository would fulfill Target, so it can be used in Copy(). What are the other content.* interfaces that it implements, and why does it need them?

@shizhMSFT
Copy link
Contributor Author

registry.Registry which provides for interactions with a registry. Of course, I can use a registry.Registry to get a registry.Repository, which satisfies a Target, which is usable with Copy(). Is that it?

@deitch Yes, exactly.

Behind the scene, oras and oras-go are envolving into a full registry client in addition to its content Copy() functionality. Since it is a full registry client, it would be better to promote the content/registry package to the top level (i.e. registry as it is in the PR). @jdolitsky @sajayantony Any votes on the package path?

What are the other content.* interfaces that it implements, and why does it need them?

Besides oras.Target, the registry.Repository interface includes content.Deleter so that it can delete a blob or a manifest since it is a full registry client. Note that both oras.Target and BlobStore have content.Storage and content.Resolver.
For other interfaces like TagPusher, Blobs(), Manifests(), Tags(), I've documented them and they are there for the functionalities of a registry client.

@shizhMSFT
Copy link
Contributor Author

shizhMSFT commented Dec 5, 2021

To get the full picture, you may take a look at my current working branch, which I will make a PR and send it out after this PR is merged.

Here are some example usages (note: I am still implementing the auth):

src, err := distribution.NewRepository("localhost:5000/hello-world")
check(err)
src.PlainHTTP = true

dst, err := distribution.NewRepository("localhost:5001/hello")
check(err)
dst.PlainHTTP = true

desc, err := oras.Copy(ctx, src, "latest", dst, "")
check(err)
src, err := distribution.NewRepository("mcr.microsoft.com/hello-world:latest")
check(err)

dst := memory.New()

_, err = oras.Copy(ctx, src, src.Reference.String(), dst, "")
check(err)
reg, err := distribution.NewRegistry("localhost:5000")
check(err)
reg.PlainHTTP = true
catalog, err := registry.Repositories(ctx, reg)
check(err)
fmt.Println(catalog)

repo, err := reg.Repository(ctx, "alpine")
check(err)
tags, err := registry.Tags(ctx, repo)
check(err)
fmt.Println(tags)

where the full package name of distribution is oras.land/oras-go/v2/registry/distribution.

@deitch
Copy link
Contributor

deitch commented Dec 5, 2021

Thanks for the explanation @shizhMSFT ; makes sense.

I do think we need clearer docs explaining what the high level interfaces are (primarily two: Copy and Registry`), but that needs to be fixed here and can come later.

@shizhMSFT
Copy link
Contributor Author

We definitely will document the library in the oras-www repo.

@shizhMSFT shizhMSFT merged commit 99e2fde into oras-project:main Dec 6, 2021
ORAS CLI/Go-lib Project Board automation moved this from Backlog to Done Dec 6, 2021
@shizhMSFT shizhMSFT deleted the registry_interface branch December 6, 2021 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Registry Interface
4 participants