Proper use of Figaro with Heroku (keys upcase/downcase appear twice)

264 Views Asked by At

I'm using Heroku, and when I display the config vars:

=== someapp-staging Config Vars
DATABASE_URL:                           xxx
LANG:                                   en_US.UTF-8
NEW_RELIC_LICENSE_KEY:                  xxx
NEW_RELIC_LOG:                          stdout
RACK_ENV:                               staging
RAILS_ENV:                              staging
SENDGRID_PASSWORD:                      123456
SENDGRID_USERNAME:                      [email protected]
WEBSOLR_URL:                            https://index.websolr.com/solr/0e1122334455
sendgrid_password:                      654321
sendgrid_username:                      [email protected]
websolr_url:                            https://index.websolr.com/solr/0e1122334455

... some are defined more than once.

Heroku' advice is to set all vars with uppercased keys. From https://devcenter.heroku.com/articles/add-ons:

Alias names must always conform to the same naming conventions as config vars.They must begin with a letter and can only contain uppercase alphanumeric characters or underscores.

1

So... when we execute figaro heroku:set --remote staging -e staging for example, why Figaro doesn't automatically set the keys to uppercase?

2

What to do next? Must I set the vars in application.yml with mixed keys like:

staging:
  <<: *default
  app_name: 'someapp (staging)'
  SENDGRID_USERNAME: [email protected]
  SENDGRID_PASSWORD: 123456
  WEBSOLR_URL: 'https://index.websolr.com/solr/0e1122334455'
  geocoder_api_key: 'azertyuiop123456789'
  airbrake_project_id: "987654"
  airbrake_project_key: 'a123456z789456123'

Thank you


ps: those are not my real credentials.


update (from laserlemon answer)

https://github.com/laserlemon/figaro/issues/238

You should write your application.yml to the exact case your application will use. While Heroku suggests a certain convention, there's no guarantee that everybody will (or can) use that convention consistently across the board. For that reason, Figaro won't automatically upcase, downcase, or otherwise. Hope that makes sense!

1

There are 1 best solutions below

0
On

Best answer from Heroku:

The behaviour of config vars in this case is due to the underlying Linux operating system being case sensitive. "Behind the scenes" config vars are just a way of managing Unix environment variables to be set on the dynos and as such, our handling of these is fairly minimal to keep them consistent with any other Linux based hosts - if we started adapting the case automatically you might find situations where it didn't work locally whereas it did on Heroku.