google-cloud-platform - Bitbucket 使用 terraform 进行源 repo 镜像

标签 google-cloud-platform bitbucket terraform terraform-provider-gcp

我正在尝试自动化项目和资源创建,以及使用 Terraform 自动化云构建触发器。要使用云构建触发器,我必须将位桶存储库镜像到 GCP 的源存储库中。

我正在使用下面的代码创建一个源项目 https://www.terraform.io/docs/providers/google/r/cloudbuild_trigger.html , 但没有设置镜像的选项。

在挖掘 GCP ( https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos/create ) 的 API 后,我可以看到一个 mirrorConfig 选项,但文档说它处于只读模式。当我为 API 设置 mirrorConfig 时,出现以下错误。

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "repo.mirror_config",
            "description": "mirror_config is a read-only field and must not be set"
          }
        ]
      }

有没有一种方法可以使用 terraform 自动从位桶到 GCP 中的源存储库进行 repo 镜像?如果没有,是否有任何替代方法/工具可以实现这一目标?

最佳答案

正如您提到的(以及 documentation 中所述)“mirrorConfig”字段当前设置为只读,因此无法手动为其设置任何值。随后,您收到了上述错误以及相应的消息描述。

设置镜像需要额外的信息,因为 Cloud Source Repositories 需要来自 Bitbucket 的授权,这是 SourceRepo API 中没有公开的操作。

“mirrorConfig”在创建时是只读的,因为在使用 Cloud Console 时,需要用户从同一浏览器 session 登录到 Cloud 和 Bitbucket 站点才能提供此额外的必需信息。但是,API 没有处理此问题的能力。

目前似乎无法通过 API 镜像存储库。要自动创建镜像存储库,除了使用 UI 之外没有其他解决方法,因此您必须通过 Cloud Console 连接到外部源,如 Mirroring a Bitbucket repository 中所述。文档。

然而,在我的调查过程中,我遇到了一个 Public Issue关于这一点,但指的是 GitHub。您可以在此公共(public)问题上添加评论,以包括 Bitbucket 的功能以及“星标”它,以便它获得更多可见度,以便您可以收到有关它的进一步更新。

希望这些信息对您有所帮助。

关于google-cloud-platform - Bitbucket 使用 terraform 进行源 repo 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59209755/

相关文章:

amazon-web-services - 在已承担角色的 EC2 实例上运行 ecr 命令需要哪些 iam 策略?

google-cloud-platform - 尽管有防火墙规则,谷歌云计算引擎拒绝连接

google-cloud-platform - 使用 TaggedOutputs 的数据流中断, "can' t pickle WeakDictionary”

git - 在克隆之前查看 git 存储库 (bitbucket) 的大小

git push 提交到不同的分支

amazon-web-services - aws terraform cloudwatch 规则作为 lambda 触发器

javascript - 无法加载默认凭据? (Node.js 谷歌计算引擎教程)

firebase - 使用 Firebase Export Collections to BigQuery 扩展将 Firestore 数据以表格格式存储在 BigQuery 中

git - 我需要从 Bitbucket Git 存储库中 check out 单个文件夹

foreach - 重构后如何保留 terraform 资源以使用 for_each?