谷歌云函数环境变量 [英] Google Cloud Functions Environment Variables

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

问题描述

是否可以为 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?

我只需要一种机制来参数化所有环境,例如 local-dev、dev、stage、prod 函数.现在,我正在尝试设置本地数据存储模拟器并设置本地开发/调试/测试工作流程,而无需在代码中编写 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,如 此处所述(请参阅开始之前")

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

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