Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add redirect support like gopkg.in #1282

Closed
Xuanwo opened this issue Jun 12, 2019 · 6 comments
Closed

Proposal: Add redirect support like gopkg.in #1282

Xuanwo opened this issue Jun 12, 2019 · 6 comments

Comments

@Xuanwo
Copy link

Xuanwo commented Jun 12, 2019

Is your feature request related to a problem? Please describe.

Our gitlab looks like: git.internal.example.com, and the repo url is something like: git.internal.example.com/cool_project/common-go. The project could be long history or complex so that we can't name it like cool_project/common which make them hard to import.

We tried to import all golang package in the same way like:

example.com/common
example.com/cool_project/common
example.com/cool_project/rpc

Currently, we have to replace them in every modules.

Describe the solution you'd like

Add config for goproxy level redirect/replace like gopkg.in do but without version suffix, we just redirect to correct VCS or next proxy (already implemented).

  • module level

git.internal.example.com/cool_project/common-go => example.com/cool_project/common

  • domain level

git.internal.example.com => example.com

Additional context

golang/go#26334 discussed GOPROXY=proxy1,proxy2,proxy3 and GONOPROXY support on the go get side.

@alexejk
Copy link
Contributor

alexejk commented Jun 18, 2019

Could this not be handled by a vanity url approach?
https://golang.org/cmd/go/#hdr-Remote_import_paths

Something like this could do a trick: https://github.com/GoogleCloudPlatform/govanityurls

We have a custom implementation in place that basically allows Athens go binary to query example.com/cool_project/common and it returns the following content that the binary follows rules on.

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="go-import" content="example.com/cool_project/common git https://git.internal.example.com/cool_project/common">
</head>
<body>
Nothing to see
</body>
</html>

This naturally means that Athens should still be able to access git.internal.example.com and have correct credentials, etc. You could swap to ssh:// instead of https:// if that's the configuration you prefer.

This might not be ideal but this could work I think. I'm also not sure if one would want to mix this or similar functionality with what Athens does today.

I can also foresee some weird situations where transformed module file will not be exactly what you expect current local version to be when working and rules are updated.

@jpreese
Copy link
Contributor

jpreese commented Aug 6, 2019

I think this would be a good candidate for a vanity url server, but I'd love to see the functionality of a vanity url server supported by Athens. This way there isn't yet another service to deploy, monitor, maintain etc.

If we bought a url such as myurl.com, and a module hosted there at mymodule, if I could redirect all requests to Athens and have Athens generate a meta tag for me based on some url -> VCS mapping, I think that would be huge.

@waitpigfly
Copy link

waitpigfly commented May 6, 2020

For big company has many developers, go get from github is slow and duplicate.

A solution is mirroring github repo(eg. https://github.com/kubernetes/api)
from inner gitlab (eg. https://mygit.com/kubernetes/api)
https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html
then athens redirect k8s.io/api to mygit.com/kubernetes/api.

Athens act as a rewrite proxy without persist(inner gitlab act as a backend storage)

Use git server as storage backend for Athens is better.

@Xuanwo
Copy link
Author

Xuanwo commented May 6, 2020

I Implement this feature in https://github.com/Xuanwo/go-mod-redirect

@arschles
Copy link
Member

@Xuanwo that's great! Thank you for letting us know

@arschles
Copy link
Member

It looks like we have two valid solutions, go-mod-redirect and govanityurls. I'm going to close this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants