Fixing RegistryAuth for image pulls

Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
Nishant Totla 2016-05-25 17:35:28 -07:00
parent 46ba8763be
commit 89277806cb
No known key found for this signature in database
GPG Key ID: 7EA5781C9B3D0C19
1 changed files with 17 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package cluster
import (
"crypto/tls"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@ -957,16 +958,27 @@ func (e *Engine) CreateVolume(request *types.VolumeCreateRequest) (*Volume, erro
}
// encodeAuthToBase64 serializes the auth configuration as JSON base64 payload
func encodeAuthToBase64(authConfig *types.AuthConfig) (string, error) {
if authConfig == nil {
return "", nil
}
buf, err := json.Marshal(*authConfig)
if err != nil {
return "", err
}
return base64.URLEncoding.EncodeToString(buf), nil
}
// Pull an image on the engine
func (e *Engine) Pull(image string, authConfig *types.AuthConfig) error {
// TODO(nishanttotla): RegistryAuth needs fixing
registryAuth := ""
if authConfig != nil {
registryAuth = authConfig.Auth
encodedAuth, err := encodeAuthToBase64(authConfig)
if err != nil {
return err
}
pullOpts := types.ImagePullOptions{
All: false,
RegistryAuth: registryAuth,
RegistryAuth: encodedAuth,
PrivilegeFunc: nil,
}
// image is a ref here