Update fsouza in order to get identityToken (#1187)

This commit is contained in:
Srinidhi Chokkadi Puranik
2018-08-24 14:58:09 -07:00
committed by Reed Allman
parent 1b51cca7b6
commit a99194434b
12 changed files with 59 additions and 13 deletions

5
Gopkg.lock generated
View File

@@ -133,8 +133,7 @@
"internal/jsonmessage",
"internal/term"
]
revision = "8842d40dbf5ee062d80f9dc429db31a0fe0cdc73"
version = "v1.2.2"
revision = "ddfe58fbc21ae55e43040f0fef017a5fddb8e54f"
[[projects]]
name = "github.com/garyburd/redigo"
@@ -502,6 +501,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "6a60a2130326efcc95c191b4d0a160b2fc8770c86c6c6f5646ecd93b42e7fbb5"
inputs-digest = "dbce15832ac7b58692cd257f32b9d152d8f6ca092ac9d5723c2a313a0ce6e13d"
solver-name = "gps-cdcl"
solver-version = 1

View File

@@ -56,7 +56,7 @@ ignored = ["github.com/fnproject/fn/cli",
[[constraint]]
name = "github.com/fsouza/go-dockerclient"
version = "~1.2.0"
revision = "ddfe58fbc21ae55e43040f0fef017a5fddb8e54f"
[[constraint]]
name = "github.com/coreos/go-semver"

View File

@@ -51,6 +51,7 @@ Damon Wang
Dan Williams
Daniel, Dao Quang Minh
Daniel Garcia
Daniel Hess
Daniel Hiltgen
Daniel Nephin
Daniel Tsui
@@ -141,6 +142,7 @@ Orivej Desh
Paul Bellamy
Paul Morie
Paul Weil
Peng Yin
Peter Edge
Peter Jihoon Kim
Peter Teich

View File

@@ -3,8 +3,8 @@
version = "v0.4.5"
[[constraint]]
branch = "master"
name = "github.com/docker/docker"
revision = "3dfb26ab3cbf961298f8ce3f94659b5fe4146ceb"
[[constraint]]
name = "github.com/docker/go-units"

View File

@@ -27,6 +27,11 @@ type AuthConfiguration struct {
Password string `json:"password,omitempty"`
Email string `json:"email,omitempty"`
ServerAddress string `json:"serveraddress,omitempty"`
// IdentityToken can be supplied with the identitytoken response of the AuthCheck call
// see https://godoc.org/github.com/docker/docker/api/types#AuthConfig
// It can be used in place of password not in conjunction with it
IdentityToken string `json:"identitytoken,omitempty"`
}
// AuthConfigurations represents authentication options to use for the
@@ -44,6 +49,7 @@ type AuthConfigurations119 map[string]AuthConfiguration
type dockerConfig struct {
Auth string `json:"auth"`
Email string `json:"email"`
IdentityToken string `json:"identitytoken"`
}
// NewAuthConfigurationsFromFile returns AuthConfigurations from a path containing JSON
@@ -128,6 +134,7 @@ func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) {
c := &AuthConfigurations{
Configs: make(map[string]AuthConfiguration),
}
for reg, conf := range confs {
if conf.Auth == "" {
continue
@@ -136,17 +143,28 @@ func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) {
if err != nil {
return nil, err
}
userpass := strings.SplitN(string(data), ":", 2)
if len(userpass) != 2 {
return nil, ErrCannotParseDockercfg
}
c.Configs[reg] = AuthConfiguration{
authConfig := AuthConfiguration{
Email: conf.Email,
Username: userpass[0],
Password: userpass[1],
ServerAddress: reg,
}
// if identitytoken provided then zero the password and set it
if conf.IdentityToken != "" {
authConfig.Password = ""
authConfig.IdentityToken = conf.IdentityToken
}
c.Configs[reg] = authConfig
}
return c, nil
}

View File

@@ -148,6 +148,7 @@ func TestAuthAndOtherFields(t *testing.T) {
t.Errorf(`AuthConfigurations.Configs["docker.io"].ServerAddress: wrong result. Want %q. Got %q`, want, got)
}
}
func TestAuthConfig(t *testing.T) {
t.Parallel()
auth := base64.StdEncoding.EncodeToString([]byte("user:pass"))
@@ -174,6 +175,27 @@ func TestAuthConfig(t *testing.T) {
}
}
func TestAuthConfigIdentityToken(t *testing.T) {
t.Parallel()
auth := base64.StdEncoding.EncodeToString([]byte("someuser:"))
read := strings.NewReader(fmt.Sprintf(`{"auths":{"docker.io":{"auth":"%s","identitytoken":"sometoken"}}}`, auth))
ac, err := NewAuthConfigurations(read)
if err != nil {
t.Fatal(err)
}
c, ok := ac.Configs["docker.io"]
if !ok {
t.Error("NewAuthConfigurations: Expected Configs to contain docker.io")
}
if got, want := c.Username, "someuser"; got != want {
t.Errorf(`AuthConfigurations.Configs["docker.io"].Username: wrong result. Want %q. Got %q`, want, got)
}
if got, want := c.IdentityToken, "sometoken"; got != want {
t.Errorf(`AuthConfigurations.Configs["docker.io"].IdentityToken: wrong result. Want %q. Got %q`, want, got)
}
}
func TestAuthCheck(t *testing.T) {
t.Parallel()
fakeRT := &FakeRoundTripper{status: http.StatusOK}

View File

@@ -788,6 +788,7 @@ type HostConfig struct {
IOMaximumIOps int64 `json:"IOMaximumIOps,omitempty" yaml:"IOMaximumIOps,omitempty"`
Mounts []HostMount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"`
Init bool `json:",omitempty" yaml:",omitempty"`
Runtime string `json:"Runtime,omitempty" yaml:"Runtime,omitempty" toml:"Runtime,omitempty"`
}
// NetworkingConfig represents the container's networking configuration for each of its interfaces

View File

@@ -156,7 +156,7 @@ func (env *Env) SetAuto(key string, value interface{}) {
// Map returns the map representation of the env.
func (env *Env) Map() map[string]string {
if len(*env) == 0 {
if env == nil || len(*env) == 0 {
return nil
}
m := make(map[string]string)

View File

@@ -143,7 +143,7 @@ type PluginDetail struct {
ID string `json:"Id,omitempty" yaml:"Id,omitempty" toml:"Id,omitempty"`
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Tag string `json:"Tag,omitempty" yaml:"Tag,omitempty" toml:"Tag,omitempty"`
Active bool `json:"Active,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
Active bool `json:"Enabled,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
Settings PluginSettings `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
}

View File

@@ -66,7 +66,7 @@ const (
"Id": "5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078",
"Name": "tiborvass/sample-volume-plugin",
"Tag": "latest",
"Active": true,
"Enabled": true,
"Settings": {
"Env": [
"DEBUG=0"

View File

@@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"net/http"
"time"
)
var (
@@ -28,6 +29,7 @@ type Volume struct {
Mountpoint string `json:"Mountpoint,omitempty" yaml:"Mountpoint,omitempty" toml:"Mountpoint,omitempty"`
Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty" toml:"Labels,omitempty"`
Options map[string]string `json:"Options,omitempty" yaml:"Options,omitempty" toml:"Options,omitempty"`
CreatedAt time.Time `json:"CreatedAt,omitempty" yaml:"CreatedAt,omitempty" toml:"CreatedAt,omitempty"`
}
// ListVolumesOptions specify parameters to the ListVolumes function.

View File

@@ -18,12 +18,14 @@ func TestListVolumes(t *testing.T) {
{
"Name": "tardis",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/tardis"
"Mountpoint": "/var/lib/docker/volumes/tardis",
"CreatedAt": "2017-07-19T12:00:26Z"
},
{
"Name": "foo",
"Driver": "bar",
"Mountpoint": "/var/lib/docker/volumes/bar"
"Mountpoint": "/var/lib/docker/volumes/bar",
"CreatedAt": "2017-07-19T12:01:26Z"
}
]`
body := `{ "Volumes": ` + volumesData + ` }`