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

View File

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

View File

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

View File

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

View File

@@ -27,6 +27,11 @@ type AuthConfiguration struct {
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
Email string `json:"email,omitempty"` Email string `json:"email,omitempty"`
ServerAddress string `json:"serveraddress,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 // AuthConfigurations represents authentication options to use for the
@@ -44,6 +49,7 @@ type AuthConfigurations119 map[string]AuthConfiguration
type dockerConfig struct { type dockerConfig struct {
Auth string `json:"auth"` Auth string `json:"auth"`
Email string `json:"email"` Email string `json:"email"`
IdentityToken string `json:"identitytoken"`
} }
// NewAuthConfigurationsFromFile returns AuthConfigurations from a path containing JSON // NewAuthConfigurationsFromFile returns AuthConfigurations from a path containing JSON
@@ -128,6 +134,7 @@ func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) {
c := &AuthConfigurations{ c := &AuthConfigurations{
Configs: make(map[string]AuthConfiguration), Configs: make(map[string]AuthConfiguration),
} }
for reg, conf := range confs { for reg, conf := range confs {
if conf.Auth == "" { if conf.Auth == "" {
continue continue
@@ -136,17 +143,28 @@ func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
userpass := strings.SplitN(string(data), ":", 2) userpass := strings.SplitN(string(data), ":", 2)
if len(userpass) != 2 { if len(userpass) != 2 {
return nil, ErrCannotParseDockercfg return nil, ErrCannotParseDockercfg
} }
c.Configs[reg] = AuthConfiguration{
authConfig := AuthConfiguration{
Email: conf.Email, Email: conf.Email,
Username: userpass[0], Username: userpass[0],
Password: userpass[1], Password: userpass[1],
ServerAddress: reg, 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 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) t.Errorf(`AuthConfigurations.Configs["docker.io"].ServerAddress: wrong result. Want %q. Got %q`, want, got)
} }
} }
func TestAuthConfig(t *testing.T) { func TestAuthConfig(t *testing.T) {
t.Parallel() t.Parallel()
auth := base64.StdEncoding.EncodeToString([]byte("user:pass")) 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) { func TestAuthCheck(t *testing.T) {
t.Parallel() t.Parallel()
fakeRT := &FakeRoundTripper{status: http.StatusOK} fakeRT := &FakeRoundTripper{status: http.StatusOK}

View File

@@ -788,6 +788,7 @@ type HostConfig struct {
IOMaximumIOps int64 `json:"IOMaximumIOps,omitempty" yaml:"IOMaximumIOps,omitempty"` IOMaximumIOps int64 `json:"IOMaximumIOps,omitempty" yaml:"IOMaximumIOps,omitempty"`
Mounts []HostMount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"` Mounts []HostMount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"`
Init bool `json:",omitempty" yaml:",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 // 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. // Map returns the map representation of the env.
func (env *Env) Map() map[string]string { func (env *Env) Map() map[string]string {
if len(*env) == 0 { if env == nil || len(*env) == 0 {
return nil return nil
} }
m := make(map[string]string) 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"` ID string `json:"Id,omitempty" yaml:"Id,omitempty" toml:"Id,omitempty"`
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"` Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Tag string `json:"Tag,omitempty" yaml:"Tag,omitempty" toml:"Tag,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"` Settings PluginSettings `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"` Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
} }

View File

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

View File

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

View File

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