Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 186ba97

Browse files
authored
Merge pull request #29 from brainly/fix_dynamic_password_resolution
Fixed dynamic password resolution for provider
2 parents 4c0165e + b31165e commit 186ba97

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

redshift/provider.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,16 @@ func resolveCredentials(d *schema.ResourceData) (string, string, error) {
163163
if (!ok) || username == nil {
164164
return "", "", fmt.Errorf("Username is required")
165165
}
166-
password, passwordIsSet := d.GetOk("password")
167-
_, clusterIdentifierIsSet := d.GetOk("temporary_credentials.0.cluster_identifier")
168-
if !passwordIsSet && !clusterIdentifierIsSet {
169-
return "", "", fmt.Errorf("password or temporary_credentials must be configured")
166+
if _, useTemporaryCredentials := d.GetOk("temporary_credentials.0"); useTemporaryCredentials {
167+
log.Println("[DEBUG] using temporary credentials authentication")
168+
dbUser, dbPassword, err := temporaryCredentials(username.(string), d)
169+
log.Printf("[DEBUG] got temporary credentials with username %s\n", dbUser)
170+
return dbUser, dbPassword, err
170171
}
171-
if passwordIsSet {
172-
if password.(string) != "" {
173-
log.Println("[DEBUG] using password authentication")
174-
return username.(string), password.(string), nil
175-
}
176-
}
177-
log.Println("[DEBUG] using temporary credentials authentication")
178-
dbUser, dbPassword, err := temporaryCredentials(username.(string), d)
179-
log.Printf("[DEBUG] got temporary credentials with username %s\n", dbUser)
180-
return dbUser, dbPassword, err
172+
173+
password, _ := d.GetOk("password")
174+
log.Println("[DEBUG] using password authentication")
175+
return username.(string), password.(string), nil
181176
}
182177

183178
// temporaryCredentials gets temporary credentials using GetClusterCredentials

0 commit comments

Comments
 (0)