Skip to content

Commit

Permalink
Add alternative credentials claim for host.
Browse files Browse the repository at this point in the history
Adresses #167
  • Loading branch information
ihrigb committed Jun 20, 2018
1 parent ce489e3 commit 619d1cc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions exporter/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ func GetCloudFoundryRedisBindings() (addrs, passwords, aliases []string) {

for _, redisService := range redisServices {
credentials := redisService.Credentials
addr := credentials["hostname"].(string) + ":" + credentials["port"].(string)
password := credentials["password"].(string)
host := getAlternative(credentials, "host", "hostname")
port := getAlternative(credentials, "port")
password := getAlternative(credentials, "password")

addr := host + ":" + port
alias := redisService.Name

addrs = append(addrs, addr)
Expand All @@ -97,3 +100,12 @@ func GetCloudFoundryRedisBindings() (addrs, passwords, aliases []string) {

return
}

func getAlternative(credentials map[string]interface{}, alternatives ...string) string {
for _, key := range alternatives {
if value, ok := credentials[key]; ok {
return value.(string)
}
}
return ""
}

0 comments on commit 619d1cc

Please sign in to comment.