Skip to content

Commit

Permalink
plumb the dockerutils to deal with two auth config types
Browse files Browse the repository at this point in the history
  • Loading branch information
mfojtik authored and soltysh committed Oct 31, 2017
1 parent d13e9a4 commit a8ca179
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/build/builder/dockerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"time"

dockertypes "github.com/docker/docker/api/types"
enginetypes "github.com/docker/engine-api/types"
docker "github.com/fsouza/go-dockerclient"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

Expand Down Expand Up @@ -234,13 +234,22 @@ func buildDirectImage(dir string, ignoreFailures bool, opts *docker.BuildImageOp
Email: v.Email,
}
}

keyring := credentialprovider.BasicDockerKeyring{}
keyring.Add(keys)
e.AuthFn = func(name string) ([]dockertypes.AuthConfig, bool) {
e.AuthFn = func(name string) ([]enginetypes.AuthConfig, bool) {
authConfs, found := keyring.Lookup(name)
var out []dockertypes.AuthConfig
var out []enginetypes.AuthConfig
for _, conf := range authConfs {
out = append(out, conf.AuthConfig)
c := enginetypes.AuthConfig{
Username: conf.Username,
Password: conf.Password,
Email: conf.Email,
ServerAddress: conf.ServerAddress,
IdentityToken: conf.IdentityToken,
RegistryToken: conf.RegistryToken,
}
out = append(out, c)
}
return out, found
}
Expand Down

0 comments on commit a8ca179

Please sign in to comment.