mirror of https://github.com/docker/docs.git
Vendor bump of dockerclient
This adds the new auth client token support. Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
This commit is contained in:
parent
67a4d559db
commit
f0b785a206
|
@ -125,7 +125,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/samalba/dockerclient",
|
||||
"Rev": "9445e25ed06943cf2828bce5a92391d768513d21"
|
||||
"Rev": "4656b1bc6cbc06b75d65983475e4809cbd53ebb5"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/samuel/go-zookeeper/zk",
|
||||
|
|
|
@ -8,9 +8,10 @@ import (
|
|||
|
||||
// AuthConfig hold parameters for authenticating with the docker registry
|
||||
type AuthConfig struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
RegistryToken string `json:"registrytoken,omitempty"`
|
||||
}
|
||||
|
||||
// encode the auth configuration struct into base64 for the X-Registry-Auth header
|
||||
|
|
|
@ -21,8 +21,9 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrImageNotFound = errors.New("Image not found")
|
||||
ErrNotFound = errors.New("Not found")
|
||||
ErrImageNotFound = errors.New("Image not found")
|
||||
ErrNotFound = errors.New("Not found")
|
||||
ErrConnectionRefused = errors.New("Cannot connect to the docker engine endpoint")
|
||||
|
||||
defaultTimeout = 30 * time.Second
|
||||
)
|
||||
|
@ -100,6 +101,9 @@ func (client *DockerClient) doStreamRequest(method string, path string, in io.Re
|
|||
if !strings.Contains(err.Error(), "connection refused") && client.TLSConfig == nil {
|
||||
return nil, fmt.Errorf("%v. Are you trying to connect to a TLS-enabled daemon without TLS?", err)
|
||||
}
|
||||
if strings.Contains(err.Error(), "connection refused") {
|
||||
return nil, ErrConnectionRefused
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode == 404 {
|
||||
|
@ -184,7 +188,7 @@ func (client *DockerClient) InspectContainer(id string) (*ContainerInfo, error)
|
|||
return info, nil
|
||||
}
|
||||
|
||||
func (client *DockerClient) CreateContainer(config *ContainerConfig, name string) (string, error) {
|
||||
func (client *DockerClient) CreateContainer(config *ContainerConfig, name string, auth *AuthConfig) (string, error) {
|
||||
data, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -195,14 +199,22 @@ func (client *DockerClient) CreateContainer(config *ContainerConfig, name string
|
|||
v.Set("name", name)
|
||||
uri = fmt.Sprintf("%s?%s", uri, v.Encode())
|
||||
}
|
||||
data, err = client.doRequest("POST", uri, data, nil)
|
||||
headers := map[string]string{}
|
||||
if auth != nil {
|
||||
encoded_auth, err := auth.encode()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
headers["X-Registry-Auth"] = encoded_auth
|
||||
}
|
||||
data, err = client.doRequest("POST", uri, data, headers)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
result := &RespContainersCreate{}
|
||||
err = json.Unmarshal(data, result)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", fmt.Errorf(string(data))
|
||||
}
|
||||
return result.Id, nil
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func main() {
|
|||
}
|
||||
|
||||
containerConfig := &dockerclient.ContainerConfig{Image: "busybox", Cmd: []string{"sh"}}
|
||||
containerId, err := docker.CreateContainer(containerConfig, "")
|
||||
containerId, err := docker.CreateContainer(containerConfig, "", nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ type Client interface {
|
|||
ListContainers(all, size bool, filters string) ([]Container, error)
|
||||
InspectContainer(id string) (*ContainerInfo, error)
|
||||
InspectImage(id string) (*ImageInfo, error)
|
||||
CreateContainer(config *ContainerConfig, name string) (string, error)
|
||||
CreateContainer(config *ContainerConfig, name string, authConfig *AuthConfig) (string, error)
|
||||
ContainerLogs(id string, options *LogOptions) (io.ReadCloser, error)
|
||||
ContainerChanges(id string) ([]*ContainerChanges, error)
|
||||
ExecCreate(config *ExecConfig) (string, error)
|
||||
|
|
|
@ -35,8 +35,8 @@ func (client *MockClient) InspectImage(id string) (*dockerclient.ImageInfo, erro
|
|||
return args.Get(0).(*dockerclient.ImageInfo), args.Error(1)
|
||||
}
|
||||
|
||||
func (client *MockClient) CreateContainer(config *dockerclient.ContainerConfig, name string) (string, error) {
|
||||
args := client.Mock.Called(config, name)
|
||||
func (client *MockClient) CreateContainer(config *dockerclient.ContainerConfig, name string, authConfig *dockerclient.AuthConfig) (string, error) {
|
||||
args := client.Mock.Called(config, name, authConfig)
|
||||
return args.String(0), args.Error(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func (client *NopClient) InspectImage(id string) (*dockerclient.ImageInfo, error
|
|||
return nil, ErrNoEngine
|
||||
}
|
||||
|
||||
func (client *NopClient) CreateContainer(config *dockerclient.ContainerConfig, name string) (string, error) {
|
||||
func (client *NopClient) CreateContainer(config *dockerclient.ContainerConfig, name string, authConfig *dockerclient.AuthConfig) (string, error) {
|
||||
return "", ErrNoEngine
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue