Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Read default image creds for each request #1230

Merged
merged 1 commit into from
Jul 19, 2018
Merged
Changes from all commits
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
10 changes: 8 additions & 2 deletions registry/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ func ParseCredentials(from string, b []byte) (Credentials, error) {
}

func ImageCredsWithDefaults(lookup func() ImageCreds, configPath string) (func() ImageCreds, error) {
var defaults Credentials
// pre-flight check
bs, err := ioutil.ReadFile(configPath)
if err == nil {
defaults, err = ParseCredentials(configPath, bs)
_, err = ParseCredentials(configPath, bs)
}
if err != nil {
return nil, err
}

return func() ImageCreds {
var defaults Credentials
bs, err := ioutil.ReadFile(configPath)
if err == nil {
defaults, _ = ParseCredentials(configPath, bs)
}
imageCreds := lookup()
for k, v := range imageCreds {
newCreds := NoCredentials()
Expand Down