Claudiu Matei
Claudiu Matei

Reputation: 4101

Escaping special characters in VCAP_SERVICES

I am having some problems when I try to put some "special" character as value of my environment variable like ! ' % etc.

Is there a way to escape them?

enter image description here

Upvotes: 0

Views: 1009

Answers (2)

Moldova
Moldova

Reputation: 1651

For ordinary user-added environment variables (ie not VCAP_*), the command line will let you do it as long as you escape them from the shell in the usual ways. E.g. here I used single quotes:

$ cf set-env mjfmsb DUDE '!@#$%^&*()'
Setting env variable 'DUDE' to '!@#$%^&*()' for app mjfmsb in org mfraioli / space dev as mfraioli...
OK
TIP: Use 'cf restage mjfmsb' to ensure your env variable changes take effect
$ cf env mjfmsb | grep DUDE
DUDE: !@#$%^&*()

Not sure why the dashboard doesn't allow the same.

Upvotes: 1

data_henrik
data_henrik

Reputation: 17156

Based on what I found it is not possible to use special characters in VCAP_SERVICES and VCAP_APPLICATION, probably because of security concerns.

The workaround would be to create a user-provided service, define the variable there, bind the service to the app and retrieve the information via the service.

Upvotes: 1

Related Questions