cloudfoundry-community / node-cfenv

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

Incompatiblity with CF diego release #11

Closed vvraskin closed 9 years ago

vvraskin commented 9 years ago

Hello,

Recently we have tested our "HelloWorld" nodejs apps on the diego part of CF. As can be followed from the release notes https://github.com/cloudfoundry-incubator/diego-design-notes, several env variables inside of containers were deprecated.

The call of 'cfenv.getAppEnv' causes the following error: 'Error: cfenv: expecting VCAP_APPLICATION to contain uris when not runninng locally'

Could you please test the code on diego or let me know if I can somehow help here?

Thanks in advance.

Regards, Vadim

pmuellr commented 9 years ago

Could you please test the code on diego or let me know if I can somehow help here?

I don't have a clue as to how I would test on diego. I'm not set up to run a CF install. If there's a Docker image that just runs, zero setup time, that I can test with - or something similar - let me know. Or is anyone running some kind of a sandbox live?

With regard to the changes, I guess this is the relevant info?

Looks like we can make a fix here: lib-src/cfenv.coffee

Something like from:

uris = appEnv.app?.uris

to:

uris = appEnv.app?.uris || []

Might work. Wanna give it a try?

The equivalent line in the js file, if you don't want to futz with a build, and just whack it to try it, is here: lib/cfenv.js

That change would be something like from:

uris = (ref = appEnv.app) != null ? ref.uris : void 0;

to:

uris = (ref = appEnv.app) != null ? ref.uris : [];
pmuellr commented 9 years ago

Not a breaker, but will also want to change the reference of VCAP_APP_PORT to CF_INSTANCE_PORT. That's why you should always use the PORT environment variable (he says, wiping his brow, thankful they didn't deprecate the PORT environment variable).

pmuellr commented 9 years ago

@vvraskin - I have a branch for you to try. In your package.json dependencies, use the following instead of the cfenv version number:

cloudfoundry-community/node-cfenv#pmuellr/issue-11

You can also use that from the command-line, to install locally, without referencing your package.json:

npm install cloudfoundry-community/node-cfenv#pmuellr/issue-11

Let me know if it works, I'll push it up to npm as a new version.

vvraskin commented 9 years ago

I've checked my code with the updated version of cfenv on Diego, it seems to be working fine. So you may push it to npm.

Could you please let me know once you do that.

Thanks.

pmuellr commented 9 years ago

@vvraskin - npm has been updated to 1.0.3

pmuellr commented 9 years ago

closing as I believe this has been resolved