Google 云功能部署不工作 - firestore 事件

Google Cloud function deploy not working - firestore event

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

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 \'

当我将“(默认)”更改为 'default or any other string' 时,脚本执行得非常好。但是这样云函数就不行了,因为Firestore数据库唯一可以使用的id是'(default)',正如这个post中提到的:

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

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

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