Gcloud 云构建本地组件失败并显示错误“加载配置文件时出错:cloudbuild.Build 中的未知字段“availableSecrets””

问题描述

问候 stackoverflow 社区!第一次提问,长期用户。

我正在使用 Cloud Build Local 组件和 Secret Manager 在本地测试我的 cloudbuild.yaml 文件,但它在“availableSecrets”上失败。

错误消息:加载配置文件时出错:cloudbuild.Build 中的未知字段“availableSecrets”

  • 操作系统平台:Windows 10/WSL2/Ubuntu 18.04
  • cloud-build-local:v0.5.2
  • Docker 引擎:v20.10.2
  • Nodejs 版本:v14.15.3
  • NPM 版本:6.14.9
  • gcloud 版本:326.0.0
  • 已安装的组件:[BigQuery 命令行工具、Cloud Datastore 模拟器、Cloud SDK 核心库、Cloud Storage 命令行工具、Google Cloud Build Local Builder、gcloud Beta 命令]

有关 Cloud Build 构建文件的文档:https://cloud.google.com/cloud-build/docs/build-config 使用云构建配置机密的文档:https://cloud.google.com/cloud-build/docs/securing-builds/use-secrets 本地云构建文档:https://cloud.google.com/cloud-build/docs/build-debug-locally

执行的步骤:

  1. 向 Secret Manager 添加了机密
  2. 在 Cloud Build 和 Secrets Manager 之间启用 API
  3. 添加了 cloudbuild 服务帐户作为每个秘密密码的成员。
  4. 向 cloudbuild 用户添加了 IAM 权限 Secret Manager Secrets Accessor。我不知道我是从哪里得到这些信息的,但在这一点上,它是其他尝试将 Secret Manager 与 cloudbuild 结合使用的残余。我不确定在此处应用访问权限与应用到 Secret Manager 机密之间的区别。

命令:cloud-build-local --config=cloudbuild.staging.yaml --dryrun=false .

cloudbuild.staging.yaml:

- name: gcr.io/cloud-builders/npm
  entrypoint: 'npm'
  args: [ 'install' ]
- name: 'gcr.io/cloud-builders/gcloud'
  args: ["app","deploy"]
  env:
  - 'DAO_FACTORY=datastore'
  - 'POLL_INTERVAL=15'
  - 'PROMPT=staging>'
  - 'ENVIRONMENT=staging'
  - 'NAMESPACE=staging'
  - 'RESET_DATASTORE=false'
  secretEnv: ['ADMIN_USER','SUPER_ADMINS','BOT_TOKEN']
availableSecrets:
  secretManager:
  - versionName: projects/{project token}/secrets/SYSTEM_USER/versions/1
    env: 'ADMIN_USER'
  - versionName: projects/{project token}/secrets/SUPER_ADMINS/versions/1
    env: 'SUPER_ADMINS'
  - versionName: projects/{project token}/secrets/BOT_TOKEN/versions/2
    env: 'BOT_TOKEN'```


Tag: cloud-build-local. I guess without reputation a meaningful tag cannot be created. Maybe an esteemed community member will create this as this may be specific to cloud-build-local only.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)