Skip to content

Commit

Permalink
Double check all vars
Browse files Browse the repository at this point in the history
  • Loading branch information
digiserg committed Jan 25, 2024
1 parent 2c12476 commit 902fe03
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,20 @@ func GetDbCredentials(role string, mount string) (VaultDbSecret, error) {
return dbSecret, fmt.Errorf("vault did not return the connection details for the database")
}

hosts, _ = conn["hosts"].(string)
connectionURL, _ = conn["connection_url"].(string)
_, ok = conn["port"]
h, ok := conn["hosts"].(string)
if ok {
port = conn["port"].(json.Number).String()
hosts = h
}
c, ok := conn["connection_url"].(string)
if ok {
connectionURL = c
}

n, ok := conn["port"].(json.Number)
if ok {
port = n.String()
}

if connectionURL != "" {
connectionURL = strings.Replace(connectionURL, "{{username}}", s.Data["username"].(string), 1)
connectionURL = strings.Replace(connectionURL, "{{password}}", s.Data["password"].(string), 1)
Expand Down

0 comments on commit 902fe03

Please sign in to comment.