Skip to content

Commit

Permalink
Merge pull request #169 from ihrigb/dev-hostname
Browse files Browse the repository at this point in the history
Add alternative credentials claim for host.
  • Loading branch information
oliver006 authored Jun 23, 2018
2 parents 23970fd + 619d1cc commit e09ba23
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 e09ba23

Please sign in to comment.