Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

docs: add examples for NewStoreFromDocker and NewStoreWithFallbacks #55

Merged
merged 1 commit into from
Apr 27, 2023
Merged

docs: add examples for NewStoreFromDocker and NewStoreWithFallbacks #55

merged 1 commit into from
Apr 27, 2023

Conversation

wangxiaoxuan273
Copy link
Collaborator

@wangxiaoxuan273 wangxiaoxuan273 commented Apr 27, 2023

Resolves #49

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2023

Codecov Report

Merging #55 (c734dc8) into main (d610c11) will not change coverage.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##             main      #55   +/-   ##
=======================================
  Coverage   81.13%   81.13%           
=======================================
  Files           6        6           
  Lines         371      371           
=======================================
  Hits          301      301           
  Misses         48       48           
  Partials       22       22           
Impacted Files Coverage Δ
store.go 76.82% <ø> (ø)

example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
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

example_test.go Outdated
)

func ExampleNewStoreFromDocker() {
ds, err := credentials.NewStoreFromDocker(credentials.StoreOptions{AllowPlaintextPut: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's format the code in standard go style.

Suggested change
ds, err := credentials.NewStoreFromDocker(credentials.StoreOptions{AllowPlaintextPut: true})
ds, err := credentials.NewStoreFromDocker(credentials.StoreOptions{
AllowPlaintextPut: true,
})

Copy link
Contributor

Choose a reason for hiding this comment

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

same for the other example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed.

example_test.go Outdated
Comment on lines 31 to 34
err = ds.Put(context.Background(), "localhost:8080",
auth.Credential{
Username: "username-example",
Password: "password-example"})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err = ds.Put(context.Background(), "localhost:8080",
auth.Credential{
Username: "username-example",
Password: "password-example"})
err = ds.Put(context.Background(), "localhost:8080", auth.Credential{
Username: "username-example",
Password: "password-example",
})

Copy link
Contributor

Choose a reason for hiding this comment

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

same for the other example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed.

example_test.go Show resolved Hide resolved
example_test.go Outdated
Comment on lines 70 to 178
// get credentials from the store
cred, err := sf.Get(context.Background(), "localhost:8080")
if err != nil {
panic(err)
}
fmt.Println(cred)
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting from fallback store is not demonstrated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the function name to ExampleNewStoreWithFallbacks_configAsPrimaryStoreDockerAsFallback to demonstrate the scenario.

example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
Signed-off-by: Xiaoxuan Wang <[email protected]>
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 a191ac6 into oras-project:main Apr 27, 2023
@wangxiaoxuan273 wangxiaoxuan273 deleted the second-examples branch April 28, 2023 03:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create examples
4 participants