Merge pull request #5416 from hashicorp/b-docker-email
Fix regression with requiring docker auth email
This commit is contained in:
commit
0ffbe64503
|
@ -1664,6 +1664,60 @@ func TestDockerDriver_AuthConfiguration(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDockerDriver_AuthFromTaskConfig(t *testing.T) {
|
||||
if !tu.IsCI() {
|
||||
t.Parallel()
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
Auth DockerAuth
|
||||
AuthConfig *docker.AuthConfiguration
|
||||
Desc string
|
||||
}{
|
||||
{
|
||||
Auth: DockerAuth{},
|
||||
AuthConfig: nil,
|
||||
Desc: "Empty Config",
|
||||
},
|
||||
{
|
||||
Auth: DockerAuth{
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
Email: "foo@bar.com",
|
||||
ServerAddr: "www.foobar.com",
|
||||
},
|
||||
AuthConfig: &docker.AuthConfiguration{
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
Email: "foo@bar.com",
|
||||
ServerAddress: "www.foobar.com",
|
||||
},
|
||||
Desc: "All fields set",
|
||||
},
|
||||
{
|
||||
Auth: DockerAuth{
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
ServerAddr: "www.foobar.com",
|
||||
},
|
||||
AuthConfig: &docker.AuthConfiguration{
|
||||
Username: "foo",
|
||||
Password: "bar",
|
||||
ServerAddress: "www.foobar.com",
|
||||
},
|
||||
Desc: "Email not set",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.Desc, func(t *testing.T) {
|
||||
act, err := authFromTaskConfig(&TaskConfig{Auth: c.Auth})("test")
|
||||
require.NoError(t, err)
|
||||
require.Exactly(t, c.AuthConfig, act)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDockerDriver_OOMKilled(t *testing.T) {
|
||||
if !tu.IsCI() {
|
||||
t.Parallel()
|
||||
|
|
|
@ -82,7 +82,8 @@ func firstValidAuth(repo string, backends []authBackend) (*docker.AuthConfigurat
|
|||
// authFromTaskConfig generates an authBackend for any auth given in the task-configuration
|
||||
func authFromTaskConfig(driverConfig *TaskConfig) authBackend {
|
||||
return func(string) (*docker.AuthConfiguration, error) {
|
||||
if len(driverConfig.Auth.Email) == 0 {
|
||||
// If all auth fields are empty, return
|
||||
if len(driverConfig.Auth.Username) == 0 && len(driverConfig.Auth.Password) == 0 && len(driverConfig.Auth.Email) == 0 && len(driverConfig.Auth.ServerAddr) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &docker.AuthConfiguration{
|
||||
|
|
Loading…
Reference in New Issue