简体   繁体   English

正确使用Figaro和Heroku(按键大写/小写出现两次)

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

I'm using Heroku, and when I display the config vars: 我正在使用Heroku,并且在显示配置变量时:

=== 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:                      app123456@heroku.com
WEBSOLR_URL:                            https://index.websolr.com/solr/0e1122334455
sendgrid_password:                      654321
sendgrid_username:                      app654321@heroku.com
websolr_url:                            https://index.websolr.com/solr/0e1122334455

... some are defined more than once. ...有些定义不止一次。

Heroku' advice is to set all vars with uppercased keys. Heroku的建议是用大写键设置所有变量。 From https://devcenter.heroku.com/articles/add-ons : 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. 别名必须始终与config vars遵循相同的命名约定,它们必须以字母开头,并且只能包含大写字母数字字符或下划线。

1 1个

So... when we execute figaro heroku:set --remote staging -e staging for example, why Figaro doesn't automatically set the keys to uppercase? 所以...例如,当我们执行figaro heroku:set --remote staging -e staging ,为什么Figaro不会自动将键设置为大写?

2 2

What to do next? 接下来做什么? Must I set the vars in application.yml with mixed keys like: 我必须使用以下混合键在application.yml设置vars:

staging:
  <<: *default
  app_name: 'someapp (staging)'
  SENDGRID_USERNAME: app123456@heroku.com
  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. ps:那不是我的真实凭证。


update (from laserlemon answer) 更新(来自laserlemon答案)

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

You should write your application.yml to the exact case your application will use. 您应该将application.yml写​​入应用程序将要使用的确切大小写。 While Heroku suggests a certain convention, there's no guarantee that everybody will (or can) use that convention consistently across the board. 尽管Heroku建议了某种约定,但不能保证每个人都会(或可以)一致地使用该约定。 For that reason, Figaro won't automatically upcase, downcase, or otherwise. 因此,Figaro不会自动进行大写,小写或其他方式。 Hope that makes sense! 希望有道理!

Best answer from Heroku: 来自Heroku的最佳答案:

The behaviour of config vars in this case is due to the underlying Linux operating system being case sensitive. 这种情况下config vars的行为是由于底层Linux操作系统区分大小写。 "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. “幕后”配置变量只是管理要在dynos上设置的Unix环境变量的一种方式,因此,我们对它们的处理非常少,以使其与任何其他基于Linux的主机保持一致-如果我们开始适应这种情况您可能会自动发现它在Heroku上无法在本地运行的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails教程-大写/小写和不区分大小写的奇怪用法 - Ruby on Rails Tutorial — strange uses of upcase/downcase and case-insensitivity 推送到Heroku时出错:Figaro :: MissingKeys:缺少必需的配置密钥:[“ config.secret_key”] - Error when pushing to Heroku: Figaro::MissingKeys: Missing required configuration keys: [“config.secret_key”] 有没有办法与工头一起使用figaro? - Is there a way to use figaro with foreman? Rails figaro gem-不知道如何构建任务“ figaro:heroku”(Rails 4 / figaro gem / heroku) - Rails figaro gem - Don't know how to build task 'figaro:heroku' (Rails 4/figaro gem/heroku)) Figaro“ Figaro:Module(NoMethodError)的未定义方法`require_keys&#39;” - Figaro “undefined method `require_keys' for Figaro:Module (NoMethodError)” Figaro环境变量不会为Heroku设置 - Figaro environment variables won't set for Heroku 滑轨| figaro heroku:set“找不到命令” - Rails | figaro heroku:set “Could not find command” 启动 rails 服务器时出错:code&amp;.downcase AND region&amp;.upcase - Error while starting rails server : code&.downcase AND region&.upcase 更改Figaro gem环境变量heroku - Change Figaro gem environment variables heroku Figaro没有在application.yml中加载适当的环境 - Figaro not loading proper environment in application.yml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM