Skip to content

Commit

Permalink
Simplify GetAllCredentials
Browse files Browse the repository at this point in the history
In the exec.ErrNotFound case, set creds to nil
so that we have the ordinary handling on the main
line.

Then eliminate two consecutive if statements with the same
condition.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Jun 30, 2022
1 parent 7dfd1e9 commit 38ef0e0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/docker/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,14 @@ func GetAllCredentials(sys *types.SystemContext) (map[string]types.DockerAuthCon
creds, err := listAuthsFromCredHelper(helper)
if err != nil {
logrus.Debugf("Error listing credentials stored in credential helper %s: %v", helper, err)
}
if err != nil {
if errors.Is(err, exec.ErrNotFound) {
// It's okay if the helper doesn't exist.
creds = nil // It's okay if the helper doesn't exist.
} else {
return nil, err
}
} else {
for registry := range creds {
addKey(registry)
}
}
for registry := range creds {
addKey(registry)
}
}
}
Expand Down

0 comments on commit 38ef0e0

Please sign in to comment.