【问题标题】:Google Cloud function deploy not working - firestore event谷歌云功能部署不起作用-firestore事件
【发布时间】:2019-02-24 22:30:32
【问题描述】:

我正在尝试通过本地终端部署云功能。为此,我使用以下代码:

gcloud beta functions deploy networkcheck \
  --region=europe-west1 \
  --project=project-id \
  --entry-point functionName \
  --trigger-event providers/cloud.firestore/eventTypes/document.write \
  --trigger-resource projects/project-id/databases/(default)/documents/test/test_id \
  --runtime nodejs8

这将导致以下错误:

deploy.sh: line 7: syntax error near unexpected token `('
deploy.sh: line 7: `  --trigger-resource projects/project-id/databases/(default)/documents/test/test_id \'

当我将“(默认)”更改为“默认或任何其他字符串”时,脚本执行得非常好。但是云功能将不起作用,因为可以用于 Firestore 数据库的唯一 id 是“(默认)”,如本文所述:How to find the database id of a cloud firestore project?

这是一个错误吗?或者我可以以某种方式解决这个问题吗?

【问题讨论】:

    标签: google-cloud-firestore google-cloud-functions gcloud


    【解决方案1】:

    Parenthesis are special characters in the bash command shell. 你需要对它们进行转义,以便它们按字面意思理解,而不是由你的 shell 解释。在这里,我只是将--trigger-resource parameter 放在单引号中,这样括号就没有特殊含义了:

    --trigger-resource "projects/project-id/databases/(default)/documents/test/test_id"
    

    【讨论】:

    • @songololo 可能不是——通常暗示着对你的 shell 的理解。并非所有 shell 的工作方式都相同,并且很难记录每个可能的 shell 在每个可能的环境中的行为。
    • 我认为这可能令人困惑的原因是(默认)与 gcloud / GCP 上下文相关——大概是为了将函数与正确的默认数据库挂钩? -- 因此在用户自己的 shell 上下文中不能直观地解释。因此,当使用 gcloud cli 遇到错误时,可能会想到存在问题,例如每个原始问题的文档中有错字?
    猜你喜欢
    • 1970-01-01
    • 2019-01-30
    • 2017-08-15
    • 2021-02-26
    • 2018-09-14
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多