diff --git a/docker.go b/docker.go index 3884223..5d57cf2 100644 --- a/docker.go +++ b/docker.go @@ -170,19 +170,20 @@ func (p Plugin) Exec() error { // as opposed to config write where different registries need to be addressed differently. // It handles any changes in the authentication process across different Docker versions. - if p.BaseImagePassword != "" { - var baseConnectorLogin Login - baseConnectorLogin.Registry = p.BaseImageRegistry - baseConnectorLogin.Username = p.BaseImageUsername - baseConnectorLogin.Password = p.BaseImagePassword - - cmd := commandLogin(baseConnectorLogin) + if p.BaseImageRegistry != "" { if p.BaseImageUsername == "" { return fmt.Errorf("Username cannot be empty. The base image connector requires authenticated access. Please either use an authenticated connector, or remove the base image connector.") } if p.BaseImagePassword == "" { return fmt.Errorf("Password cannot be empty. The base image connector requires authenticated access. Please either use an authenticated connector, or remove the base image connector.") } + var baseConnectorLogin Login + baseConnectorLogin.Registry = p.BaseImageRegistry + baseConnectorLogin.Username = p.BaseImageUsername + baseConnectorLogin.Password = p.BaseImagePassword + + cmd := commandLogin(baseConnectorLogin) + raw, err := cmd.CombinedOutput() if err != nil { out := string(raw) diff --git a/internal/docker/config.go b/internal/docker/config.go index 6bd8622..1bdd600 100644 --- a/internal/docker/config.go +++ b/internal/docker/config.go @@ -52,10 +52,10 @@ func (c *Config) CreateDockerConfigJson(credentials []RegistryCredentials) ([]by if cred.Registry != "" { if cred.Username == "" { - return nil, fmt.Errorf("Username cannot be empty. The base image connector requires authenticated access. Please either use an authenticated connector, or remove the base image connector.") + return nil, fmt.Errorf("Username must be specified for registry: %s", cred.Registry) } if cred.Password == "" { - return nil, fmt.Errorf("Password cannot be empty. The base image connector requires authenticated access. Please either use an authenticated connector, or remove the base image connector.") + return nil, fmt.Errorf("Password must be specified for registry: %s", cred.Registry) } c.SetAuth(cred.Registry, cred.Username, cred.Password) }