cloudfoundry-community / node-cfenv

easy access to your Cloud Foundry application environment for node
Apache License 2.0
73 stars 20 forks source link

appEnv.getServiceCreds(spec) returning multiple values #19

Closed jeffdare closed 8 years ago

jeffdare commented 8 years ago

https://www.npmjs.com/package/cfenv#appenvgetservicecredsspec

getServiceCreds function currently returns the first matched creds of the service. But what if the same service has 2 instances, shouldn't this function return 2(in array of creds).

pmuellr commented 8 years ago

The function appEnv.getServiceCreds(spec) operates against the name, not label. Per the doc, the argument acts the same as appEnv.getServiceURL(spec), so if you specify a regex, it (presumably) returns the first match. If you pass a name, will return the service matching the name. At least when I last used CF, service names were unique within an org (or perhaps a smaller scope), but service labels could be the same for different services. So, if you have two instances of the same service, that your app is using, they have to have different names, but may well have the same labels (prolly do).

Closing, but feel free to reopen if I misread this ...