登录
首页 >  Golang >  Go问答

从AWS CodeCommit获取私有存储库时,请使用HTTPS传输保证安全

来源:stackoverflow

时间:2024-03-15 14:54:26 189浏览 收藏

IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《从AWS CodeCommit获取私有存储库时,请使用HTTPS传输保证安全》,聊聊,我们一起来看看吧!

问题内容

我正在尝试导入位于 aws codecommit 中的模块。为了克隆存储库,我使用 https grc(git 远程代码提交)方法,该方法使用 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/"

设置为私有:

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?


正确答案


终于找到解决办法了:

设置 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

终于介绍完啦!小伙伴们,这篇关于《从AWS CodeCommit获取私有存储库时,请使用HTTPS传输保证安全》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>