Google compute engine 如何将源存储库中的repo克隆到计算引擎,以便在需要时手动提取它
在我的本地macOS上,以下命令运行良好:Google compute engine 如何将源存储库中的repo克隆到计算引擎,以便在需要时手动提取它,google-compute-engine,google-iam,google-source-repositories,Google Compute Engine,Google Iam,Google Source Repositories,在我的本地macOS上,以下命令运行良好: $ gcloud source repos clone myrepo --project=myproject (尽管我不确定它是否有效,因为之前我遵循了~/.gitcookies过程) 但当我在CE上这样做时: $ gcloud source repos clone myrepo --project=myproject ERROR: (gcloud.source.repos.clone) PERMISSION_DENIED: Request had
$ gcloud source repos clone myrepo --project=myproject
(尽管我不确定它是否有效,因为之前我遵循了~/.gitcookies
过程)
但当我在CE上这样做时:
$ gcloud source repos clone myrepo --project=myproject
ERROR: (gcloud.source.repos.clone) PERMISSION_DENIED: Request had insufficient authentication scopes.
$ gcloud source repos list
ERROR: (gcloud.source.repos.list) User [<digits>-compute@developer.gserviceaccount.com] does not have permission to access project [<myproject>] (or it may not exist): Request had insufficient authentication scopes.
$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* <digits>-compute@developer.gserviceaccount.com
但是它可能包含在.get
和阅读器中,我已经尝试过:
UPD2:sudo/usr/local/share/google/google-cloud-sdk/bin/gcloud-components-update
没有帮助
我现在唯一能想到的两个选择是编辑
(这是我在互联网上发现的唯一一个似乎可以解决问题的方法,但那篇博文是用一些东方语言写的,所以我不确定)但它需要VM停止,这是不可接受的
或者伪造另一个服务帐户,但我不确定在gcloud
CLI中切换它不会破坏该机器上运行的其他应用程序。或者,在克隆repo时,我只能使用它一次,它会一直使用吗?如果您使用的是Google Compute Engine实例的服务帐户,正如您在此处所读[1]您需要将云源存储库的访问范围授予Full或read/Write。为此,必须停止实例
如果不想停止实例,可以创建一个新的服务帐户,并使用以下命令激活该服务帐户:
$gcloud auth activate服务帐户--密钥文件=[key.JSON]
这是一个开始使用gcloud工具的新服务帐户:
$gcloud init
如果在此新服务帐户中使用角色编辑器,则存在已知问题,因为角色编辑器没有source.repos.create权限
$gcloud iam角色描述角色/编辑器| grep“source.repos”
- source.repos.get
- source.repos.getIamPolicy
- source.repos.list
- source.repos.update
作为工作区,为了创建云源存储库,您需要具有以下角色:“roles/Source.admin”,如您在此处所读[2]:“提供创建、更新、删除、列出、克隆、获取和浏览存储库的权限。还提供读取和更改IAM策略的权限。”
此处[3]您可以跟踪此问题的状态,但请记住,没有固定的预计到达时间或担保
[1]
[2]
[3] 您可以通过实例设置启用对所有云API的完全访问。您需要先停止VM。只需单击实例名称,按Stop,然后等待,停止后,按Edit并检查API访问的相应设置。然后启动实例。我不创建,我克隆。要克隆存储库,必须创建一个新的存储库。
$ gcloud help source repos
COMMANDS
COMMAND is one of the following:
clone
Clone a cloud source repository.
create
Create a cloud source repository.
delete
Delete a cloud source repository.
describe
Describe a cloud source repository.
get-iam-policy
Get the IAM policy for the named cloud source repository.
list
List the repositories the currently active project.
set-iam-policy
Set the IAM policy for the named repository.