使用HTTPS GRC从AWS CodeCommit获取私有存储库。

huangapple go评论82阅读模式
英文:

Get a private repository from AWS codecommit using HTTPS GRC

问题

我正在尝试导入位于AWS CodeCommit中的一个模块。为了克隆存储库,我正在使用HTTPS GRC(Git Remote Codecommit)方法,该方法使用Google Suite凭据访问AWS控制台。

我用以下命令来克隆存储库:

git clone codecommit::us-west-2://my-module

远程模块的go.mod文件包含以下内容:

module git-codecommit.us-west-2.amazonaws.com/my-module.git

我尝试通过以下方式配置Git来实现我的目标:

git config --global url."codecommit::us-west-2://".insteadOf "https://git-codecommit.us-west-2.amazonaws.com/"

设置GOPRIVATE:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com/my-module.git

然后获取存储库:

go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git

但是我得到了以下输出(并且执行被卡住了):

cd.
git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module

我想提到的是,当我手动执行git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module命令时,我可以正常获取分支和标签的信息。

我查看了这个主题,但在那种情况下,使用的是SSH协议而不是HTTP GRC。也许从私有存储库导入模块的唯一方法是通过SSH?

英文:

I'm trying to import a module located in AWS codecommit. To clone the repository I'm using HTTPS GRC (Git Remote Codecommit) method, which uses Google Suite credentials to access AWS console.

The command I use to clone the repository is:

git clone codecommit::us-west-2://my-module

The remote module's go.mod file contains this:

module git-codecommit.us-west-2.amazonaws.com/my-module.git

I tried to achieve my goal configuring Git like this:

git config --global url."codecommit::us-west-2://".insteadOf "https://git-codecommit.us-west-2.amazonaws.com/"

Setted GOPRIVATE:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com/my-module.git

And then getting the repository:

go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git

but I get this output (and the execution gets stuck):

cd.
git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module

I would like to mention that when I execute the git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module command manually I get the information of the branches and tags without problems.

I checked this topic but in that case SSH protocol is used instead of HTTP GRC. Maybe the only way to import a module from a private repository is via SSH?

答案1

得分: 4

最后找到了解决方案:

设置Git凭据助手:

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

设置GOPRIVATE环境变量:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com

在MacOS中,禁用Git的钥匙串:

在包含该值的文件中注释掉helper = osxkeychain(运行git config -l --show-origin | grep credential查找目标文件)

运行go get命令:

go get git-codecommit.us-west-2.amazonaws.com/v1/repos/my-module.git
英文:

Finally found the solution:

Set Git credential helper:

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

Set GOPRIVATE env var:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com

In MacOS, disable keychain for Git:

Comment helper = osxkeychain in the file containing that value (run git config -l --show-origin | grep credential to find the target file)

Run go get:

go get git-codecommit.us-west-2.amazonaws.com/v1/repos/my-module.git

huangapple
  • 本文由 发表于 2021年10月22日 02:37:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/69667155.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定