mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 10:15:30 +08:00
check for registry empty
check for registry empty redo unwanted changes
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user