From c21f6f8eead4eeeed5f29d948ea69f9043a7dba5 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Mon, 22 Feb 2016 13:20:06 -0800 Subject: [PATCH] Throwing an error if Nomad can't create an docker auth object --- client/driver/docker.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index 1bf97fb33..100bc980e 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -457,18 +457,18 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle } } - if authConfig := d.config.Read("docker.auth.config"); authConfig != "" { - if f, err := os.Open(authConfig); err == nil { + if authConfigFile := d.config.Read("docker.auth.config"); authConfigFile != "" { + if f, err := os.Open(authConfigFile); err == nil { defer f.Close() - if authConfigurations, err := docker.NewAuthConfigurations(f); err == nil { - if authConfiguration, ok := authConfigurations.Configs[repo]; ok { - authOptions = authConfiguration - } - } else { + var authConfigurations *docker.AuthConfigurations + if authConfigurations, err = docker.NewAuthConfigurations(f); err != nil { return nil, fmt.Errorf("Failed to create docker auth object: %v", err) } + if authConfiguration, ok := authConfigurations.Configs[repo]; ok { + authOptions = authConfiguration + } } else { - return nil, fmt.Errorf("Failed to create auth object from file: %v, error: %v", authConfig, err) + return nil, fmt.Errorf("Failed to open auth config file: %v, error: %v", authConfigFile, err) } }