Skip to content

Commit 26bf363

Browse files
committed
feat: add empty provider config auth values check to prevent late errs
1 parent ea96a29 commit 26bf363

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

redshift/config_pq_proxy.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ func getConfigFromPqResourceData(d *schema.ResourceData, database string, maxCon
5252
var err error
5353
var password string
5454
host := d.Get("host").(string)
55+
if host == "" {
56+
return nil, fmt.Errorf("host must be specified and non-empty")
57+
}
5558
username := d.Get("username").(string)
59+
if username == "" {
60+
return nil, fmt.Errorf("username must be specified and non-empty")
61+
}
5662
port := d.Get("port").(int)
5763
sslMode := d.Get("sslmode").(string)
64+
log.Printf("[DEBUG] using username %q for authentication\n", username)
5865
_, useTemporaryCredentials := d.GetOk("temporary_credentials")
5966
if useTemporaryCredentials {
6067
log.Println("[DEBUG] using temporary credentials authentication")
@@ -66,6 +73,9 @@ func getConfigFromPqResourceData(d *schema.ResourceData, database string, maxCon
6673
} else {
6774
log.Println("[DEBUG] using password authentication")
6875
password = d.Get("password").(string)
76+
if password == "" {
77+
return nil, fmt.Errorf("password must be specified and non-empty when using password authentication")
78+
}
6979
}
7080
return NewPqConfig(host, database, username, password, port, sslMode, maxConnections), nil
7181
}

0 commit comments

Comments
 (0)