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

Add example for listing repositories in registry target #117

Merged
merged 15 commits into from
Mar 25, 2022

Conversation

qweeah
Copy link
Contributor

@qweeah qweeah commented Mar 17, 2022

This PR works for item #60 and adds an example for listing repositories.

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@shizhMSFT
Copy link
Contributor

shizhMSFT commented Mar 22, 2022

Should we create a new file named registry_example_test.go with package name remote_test, and move all examples in it?

if err != nil {
panic(err) // Handle error
}
reg.RepositoryOptions.PlainHTTP = true // Use HTTP
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified as reg.PlainHTTP = true.

Comment on lines 225 to 233
fn := func(repos []string) error { // Setup a callback function to process returned repository list
for _, repo := range repos {
fmt.Println(repo)
}
return nil
}

ctx := context.Background()
reg.Repositories(ctx, fn)
Copy link
Contributor

Choose a reason for hiding this comment

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

You may also want to show something like this first:

ctx := context.Background()
repos, err := registry.Repositories(ctx, reg)
if err != nil {
    panic(err)
}
fmt.Println(repos)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be added to another function ExampleRepositories, will do that

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@qweeah
Copy link
Contributor Author

qweeah commented Mar 23, 2022

Should we create a new file named registry_example_test.go with package name remote_test, and move all examples in it?

Done. I also added an example for the static method in registry package

registry/remote/registry_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Show resolved Hide resolved
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
registry/remote/registry_example_test.go Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/registry_example_test.go Outdated Show resolved Hide resolved
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
registry/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
registry/remote/registry_example_test.go Outdated Show resolved Hide resolved
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 6588790 into oras-project:main Mar 25, 2022
qweeah added a commit to qweeah/oras-go that referenced this pull request Mar 28, 2022
qweeah added a commit to qweeah/oras-go that referenced this pull request Mar 30, 2022
qweeah added a commit to qweeah/oras-go that referenced this pull request Apr 6, 2022
qweeah added a commit to qweeah/oras-go that referenced this pull request Apr 6, 2022
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