Skip to content

Commit 81ce3b6

Browse files
committed
check for registry empty
check for registry empty redo unwanted changes
1 parent 3c461ba commit 81ce3b6

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

docker.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,20 @@ func (p Plugin) Exec() error {
170170
// as opposed to config write where different registries need to be addressed differently.
171171
// It handles any changes in the authentication process across different Docker versions.
172172

173-
if p.BaseImagePassword != "" {
174-
var baseConnectorLogin Login
175-
baseConnectorLogin.Registry = p.BaseImageRegistry
176-
baseConnectorLogin.Username = p.BaseImageUsername
177-
baseConnectorLogin.Password = p.BaseImagePassword
178-
179-
cmd := commandLogin(baseConnectorLogin)
173+
if p.BaseImageRegistry != "" {
180174
if p.BaseImageUsername == "" {
181175
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.")
182176
}
183177
if p.BaseImagePassword == "" {
184178
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.")
185179
}
180+
var baseConnectorLogin Login
181+
baseConnectorLogin.Registry = p.BaseImageRegistry
182+
baseConnectorLogin.Username = p.BaseImageUsername
183+
baseConnectorLogin.Password = p.BaseImagePassword
184+
185+
cmd := commandLogin(baseConnectorLogin)
186+
186187
raw, err := cmd.CombinedOutput()
187188
if err != nil {
188189
out := string(raw)

internal/docker/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func (c *Config) CreateDockerConfigJson(credentials []RegistryCredentials) ([]by
5252
if cred.Registry != "" {
5353

5454
if cred.Username == "" {
55-
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.")
55+
return nil, fmt.Errorf("Username must be specified for registry: %s", cred.Registry)
5656
}
5757
if cred.Password == "" {
58-
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.")
58+
return nil, fmt.Errorf("Password must be specified for registry: %s", cred.Registry)
5959
}
6060
c.SetAuth(cred.Registry, cred.Username, cred.Password)
6161
}

0 commit comments

Comments
 (0)