如何解决谷歌云构建无法获取私有 go 模块
我在 gcloud 构建中遇到了私有模块的一些问题。我生成了一个新的 ssh 密钥对,将私钥存储在我的 gcp 项目 secretManager
中,将公共密钥存储在 github repos Deploy key
中。我按照本教程没有问题:https://cloud.google.com/build/docs/access-private-github-repos
在构建步骤中,我能够克隆我的存储库(我猜这表明我有一个有效的连接)。但是当我尝试去获取私人回购(private-repo)时,我得到以下信息:
Step #2: go: github.com/felix/private-repo@<version-nr>: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/e61704280b96667bd155fe2e6c284d9506853b470d6786a1dff7011776527149: exit status 128:
Step #2: ERROR: Repository not found.
Step #2: fatal: Could not read from remote repository.
Step #2:
Step #2: Please make sure you have the correct access rights
Step #2: and the repository exists.
Finished Step #2
我的 cloudbuild yaml 文件:
steps:
- name: 'gcr.io/cloud-builders/git'
secretEnv: ['SSH_KEY']
entrypoint: 'bash'
args:
- -c
- |
echo "$$SSH_KEY" >> /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
git config --global url."git@github.com:myOrg".insteadOf https://github.com/myOrg
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'git'
path: /root/.gitconfig
- name: 'golang'
args: ['make','review']
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'git'
path: /root/.gitconfig
availableSecrets:
secretManager:
- versionName: projects/my-project/secrets/ssh-private-key/versions/latest
env: 'SSH_KEY'
我还设置了这些 go env 变量:
GOPRIVATE=github.com/myOrg/*
GO111MODULE=on
所以看来 SSH 部分工作正常,但不知何故我无法获取我的私有依赖项。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。