How to use Go dep with GitLab subgroups

匆匆过客 提交于 2019-12-08 07:24:26

问题


I have a go project that requires some dependencies from a GitLab repository like git.mydomain.com/myteam/category/subcategory/project.git. But I'm getting this error.

ensure Solve(): remote repository at https://git.mydomain.com/myteam/category.git does not exist or is inaccessible: : exit status 128

I would really thankful if someone can help me to solve this.

Thanks.


回答1:


This issue is discussed at length on the GitLab support tracker.

TL;DR; It's (intentionally) broken for private repos:

Is [your group] private? If so, this is expected behavior, and I would recommend reading the discussion from #1337 (comment 36293613) onwards. In this case, we have decided to maximize security/privacy at the slight expense of usability. The recommended workaround is to specifically add .git to your URL.

The only solution I've found is to use dep's support for .netrc.

  1. Create a Personal Access token on GitLab with api scope:

  2. Create a ~/.netrc file:

    machine gitlab.com
        login <your gitlab username>
        password <the token created in step 1>
    
  3. Protect your .netrc file a bit:

    chmod 600 ~/.netrc
    
  4. Profit

    This should now work:

    dep ensure -add gitlab.com/<company>/<subgroup>/<project>
    

If you're using a private GitLab installation, I trust you to replace gitlab.com with the appropriate hostname where applicable.




回答2:


I think the best solution would be to use a proxy-server like athens. You could add your Gitlab-Credentials and use it as proxy-server. Athens then would handle authentication.



来源:https://stackoverflow.com/questions/56817601/how-to-use-go-dep-with-gitlab-subgroups

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!