added support for authentication against the default docker registry when provided in the .dockercfg

a
pull/6/head
Mike Danese 2014-11-06 11:11:29 -08:00
parent 9846228969
commit 1d76452bc2
1 changed files with 7 additions and 0 deletions

View File

@ -613,6 +613,8 @@ func (dk *dockerKeyring) reindex() {
sort.Sort(sort.Reverse(sort.StringSlice(dk.index))) sort.Sort(sort.Reverse(sort.StringSlice(dk.index)))
} }
const defaultRegistryHost = "index.docker.io/v1/"
func (dk *dockerKeyring) lookup(image string) (docker.AuthConfiguration, bool) { func (dk *dockerKeyring) lookup(image string) (docker.AuthConfiguration, bool) {
// range over the index as iterating over a map does not provide // range over the index as iterating over a map does not provide
// a predictable ordering // a predictable ordering
@ -624,6 +626,11 @@ func (dk *dockerKeyring) lookup(image string) (docker.AuthConfiguration, bool) {
return dk.creds[k], true return dk.creds[k], true
} }
// use credentials for the default registry if provided
if auth, ok := dk.creds[defaultRegistryHost]; ok {
return auth, true
}
return docker.AuthConfiguration{}, false return docker.AuthConfiguration{}, false
} }