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

Dan*_*yle 6 google-app-engine gcloud google-cloud-build cloudbuild.yaml

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

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

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

  • 操作系统平台:Windows 10/WSL2/Ubuntu 18.04
  • 云构建本地: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/ secure-builds/use-secrets 云构建本地文档: https: //cloud.google.com/cloud-build/docs/build-debug-locally

执行的步骤:

  1. 向秘密管理器添加秘密
  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.
Run Code Online (Sandbox Code Playgroud)

Dan*_*yle 1

Google Cloud Build 描述符文件中对 Google Secret Manager 的支持显然是非常新的,目前 cloud-build-local 组件似乎不支持;请参阅 Guillaume 关于该功能已发布一周的评论。当云构建描述符在 Cloud Build 中运行时,它工作正常。

  • 有谁知道什么时候会添加这个?我使用的是 331 版本,但它仍然不存在 (2认同)