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-credential-go to do auth #932

Merged
merged 7 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/oras/root/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func runLogin(ctx context.Context, opts loginOptions) (err error) {
if err != nil {
return err
}
// Ping to ensure credential is valid
remote, err := opts.Remote.NewRegistry(opts.Hostname, opts.Common)
if err != nil {
return err
Expand Down
12 changes: 7 additions & 5 deletions internal/credential/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ import (
)

// NewStore generates a store based on the passed-in config file paths.
func NewStore(configPaths ...string) (store credentials.Store, err error) {
so := credentials.StoreOptions{AllowPlaintextPut: true}
func NewStore(configPaths ...string) (credentials.Store, error) {
opts := credentials.StoreOptions{AllowPlaintextPut: true}
var store credentials.Store
var err error
if len(configPaths) == 0 {
// use default docker config file path
store, err = credentials.NewStoreFromDocker(so)
store, err = credentials.NewStoreFromDocker(opts)
qweeah marked this conversation as resolved.
Show resolved Hide resolved
} else {
var stores []credentials.Store
qweeah marked this conversation as resolved.
Show resolved Hide resolved
for _, config := range configPaths {
store, err := credentials.NewStore(config, so)
store, err := credentials.NewStore(config, opts)
if err != nil {
return nil, err
}
stores = append(stores, store)
}
store, err = credentials.NewStoreWithFallbacks(stores[0], stores[1:]...), nil
qweeah marked this conversation as resolved.
Show resolved Hide resolved
}
return
return store, err
}