Skip to content

Commit

Permalink
check for registry empty
Browse files Browse the repository at this point in the history
check for registry empty

redo unwanted changes
  • Loading branch information
Aishwarya-Lad committed Jul 22, 2024
1 parent 3c461ba commit 81ce3b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/docker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 81ce3b6

Please sign in to comment.