如何在Google App Engine中为Go应用设置应用范围设置?

如何在Google App Engine中为Go应用设置应用范围设置?

问题描述:

The Google App engine for Go does not accept environment variables via the app.yaml file. How do you setup application wide settings without using the environment?


In my specific case I have a watcher type webhook app (https://github.com/jjasonclark/pulltabs) that needs to handle HMAC decryption. So I need to have a secret code for this to work. I would like to deploy many copies with different secret settings, aka not hard coded. Normally this would be an environment variable settings.

Go专用的Google App引擎不通过 app.yaml code>文件接受环境变量 。 如何在不使用环境的情况下设置应用程序范围的设置? p>


在我的特定情况下,我有一个监视程序类型的webhook应用程序( https://github.com/jjasonclark/pulltabs )需要处理HMAC解密。 因此,我需要有一个密码才能起作用。 我想使用不同的秘密设置(也就是未进行硬编码)部署许多副本。 通常,这是环境变量设置。 p> div>

Some approaches that may suit depending on your needs:

  • Config file
  • Datastore

Config file Add a config file to your project and load the settings from there on app initialization. Beegae is an example of that approach. Depending on your security needs you might choose to exclude the file from git, create/update it during your deployment process or even consider multiple config files for different cases.

Datastore Store the settings in the datastore and load them on application initialization. This may be useful if settings need to be changed without redeploying the application each time, or multiple applications share the same datastore and some look-up logic for settings makes sense.