Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Merge 704d425 into 3f7db51
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerott committed Nov 16, 2017
2 parents 3f7db51 + 704d425 commit 52b358d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function IBMCloudEnv() {
return processJSONPath(vcapApplicationString, patternComponents[1]);
}
} else {
// patternComponents[1] is a service instance name, find it in VCAP_SERVIES and return credentials object
// patternComponents[1] is a service instance name, find it in VCAP_SERVICES and return credentials object
let jsonPath = '$..[?(@.name=="' + patternComponents[1] + '")].credentials';
return processJSONPath(vcapServicesString, jsonPath);
}
Expand Down
5 changes: 5 additions & 0 deletions server/config/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"cloudfoundry:$.application_name"
]
},
"cf_var4":{
"searchPatterns": [
"cloudfoundry:$.*[?(@.name == 'service1-name1')].credentials.username"
]
},
"env_var1":{
"searchPatterns": [
"env:ENV_VAR_STRING"
Expand Down
4 changes: 2 additions & 2 deletions test/fake-env-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ process.env.VCAP_SERVICES = JSON.stringify({
{
name: "service1-name1",
credentials: {
username: "service1-username1",
username: "service1-username1"
}
},
{
name: "service1-name2",
credentials: {
username: "service1-username2",
username: "service1-username2"
}
}
],
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ describe('App', function () {
expect(IBMCloudEnv.getDictionary("cf_var3")).to.be.an("object");
expect(IBMCloudEnv.getDictionary("cf_var3")).to.have.a.property("value");
expect(IBMCloudEnv.getDictionary("cf_var3").value).to.equal("test-application");

expect(IBMCloudEnv.getString("cf_var4")).to.equal("service1-username1");
expect(IBMCloudEnv.getDictionary("cf_var4")).to.be.an("object");
expect(IBMCloudEnv.getDictionary("cf_var4")).to.have.a.property("value");
expect(IBMCloudEnv.getDictionary("cf_var4").value).to.equal("service1-username1");
});

it('Should be able to get simple string from environment var', function () {
Expand Down

0 comments on commit 52b358d

Please sign in to comment.