Google Cloud Functions 环境变量 [英] Google Cloud Functions Environment Variables

查看:46
本文介绍了Google Cloud Functions 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为 GCF 设置环境变量,以便所有功能都可以看到所有设置?或者也许有一些选项可以在项目范围内配置它?

Is it possible to set environment variables for GCF so that all that settings would be visible to all functions? Or maybe there are some options to configure it in project's scope?

我只需要一种机制来参数化所有环境,例如本地开发、开发、阶段、功能的生产.现在我正在尝试设置本地数据存储模拟器并设置本地开发/调试/测试工作流程,而无需在代码中编写 if 语句.我发现这些东西可以通过 env 进行配置.veriables,但我不知道它如何在云中的目标平台上工作.

I'm just need a mechanism to parametrize all environments, like local-dev, dev, stage, prod for functions. For now I'm trying setup local datastore emulator and setup local development/debugging/testing workflow without writing if statements inside code. As I found such things can be configured through env. veriables, but I'm don't know how it would work on target platform in cloud.

在未来,分部环境将在具有自己的数据库和存储以及环境的单独云项目上进行分段.变量.

In future staging will be made by division environments onto separate cloud projects with their's own databases and storages as well as env. variables.

是否有可能或有任何解决方案?

Is it possible or is there any solution for something like that?

推荐答案

并不是说部署管理器不会以同样的方式处理这些(虽然我无法准确地发现它),下面的这听起来是最接近你的答案'正在谈论:

Not saying that Deployment Manager would not handle those the same way (although I could not spot it accurately), this below sounds like the closest answer to what you're talking about :

https://github.com/fredriks/cloud-functions-runtime-config/blob/master/README.md

除了这个示例是一个 npm 包之外,它还清楚地显示了要运行的 gcloud 命令.

Besides this example being an npm package, it shows clearly the gcloud commands to run.

激活相关 api 很重要,如此处所述(请参阅开始之前")

这篇关于Google Cloud Functions 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆