Skip to content

Add vanity-imports for modules we migrate to monorepo. #424

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

Closed
wants to merge 1 commit into from

Conversation

jankaluza
Copy link
Member

This commit adds new static .html pages which contain the metadata for go vanity imports.

This allows us to use for example podman.io/go/storage in the go.mod. Go then does HTTP query to podman.io/go/storage followed by the HTTP query to podman.io/go to find out the real URL for git repository.

If real person opens that URL in a browser, they are redirected to podman.io.

@jankaluza
Copy link
Member Author

I've tested this locally (with localhost.localdomain instead of podman.io).

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use the extra /go path? That just makes the import paths a bit ugly podman.io/go/common?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file as well? I don't think we want the top level path to be used as module or maybe I missing something about the the go vanity URL's?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it. You can check it in the https://pkg.go.dev/cmd/go@master#hdr-Remote_import_paths.

The import-prefix is the import path corresponding to the repository root. It must be a prefix or an exact match of the package being fetched with "go get". If it's not an exact match, another http request is made at the prefix to verify the tags match.

Note the "If it's not an exact match" part.

@Luap99
Copy link
Member

Luap99 commented Aug 12, 2025

Might be worth to link https://pkg.go.dev/cmd/go@master#hdr-Remote_import_paths for the proper docs one the format

@jankaluza
Copy link
Member Author

jankaluza commented Aug 12, 2025

Is there a reason to use the extra /go path? That just makes the import paths a bit ugly podman.io/go/common?

In case we use just a prefix in the content attribute of meta tag (which we have to do, because we use monorepo), the go checks both URLS:

  • podman.io/go/storage
  • podman.io/go

In case we would use podman.io/storage, go would check both podman.io/storage and podman.io. The issue is that the podman.io is generated by docusaurus javascript and I did not find any sane way to add <meta> into the <head> of the podman.io - therefore I do that in the go directory. There are ways to inject <head> using docusaurus, but it is done by javascript which is not evaluated by go client.

But maybe someone else would have some clever idea how to do it.

@jankaluza
Copy link
Member Author

Might be worth to link https://pkg.go.dev/cmd/go@master#hdr-Remote_import_paths for the proper docs one the format

Do you mean in the commit message or somewhere in the html...?

@Luap99
Copy link
Member

Luap99 commented Aug 12, 2025

Might be worth to link https://pkg.go.dev/cmd/go@master#hdr-Remote_import_paths for the proper docs one the format

Do you mean in the commit message or somewhere in the html...?

commit messsage

This commit adds new static .html pages which contain the metadata
for go vanity imports:

- https://pkg.go.dev/cmd/go@master#hdr-Remote_import_paths

This allows us to use for example `podman.io/go/storage` in the go.mod.
Go then does HTTP query to `podman.io/go/storage` followed by
the HTTP query to `podman.io/go` to find out the real URL for git
repository.

If real person opens that URL in a browser, they are redirected to
source-code for each module.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
@Luap99
Copy link
Member

Luap99 commented Aug 12, 2025

In case we would use podman.io/storage, go would check both podman.io/storage and podman.io. The issue is that the podman.io is generated by docusaurus javascript and I did not find any sane way to add <meta> into the <head> of the podman.io - therefore I do that in the go directory. There are ways to inject <head> using docusaurus, but it is done by javascript which is not evaluated by go client.

But maybe someone else would have some clever idea how to do it.

Well that is a technical problem we can most likely solve somehow. Once we commit to import paths they are locked in and updating them requires large churn for our consumers so need to avoid that as much as possible. So I rather spend some time on nicer import names but we can discus it as team what names should be used.

Also I should point out that using podman.io is a bit in conflict with CNCF ownership as the common/image/storage repos have not been transferred to CNCF. The podman.io domain is now owned by CNCF as they control repo imports we have not transferred? Maybe it doesn't matter since we like to combine everything so the libraries should becomes part of CNCF eventually as well.

Lastly, these vanity imports are quite critical and security sensitive, anyone who has control over the domain or webserver could point to different code which can comprise all people using these. So personally I am not sure sharing access here with the main site which is made up of of a ton of javascript is the best thing either. Not to mention that more people have write access here than the main code repos.

@jankaluza
Copy link
Member Author

We could probably handle go-get=1 in the react page and serve that static file instead of the real generated page. Or maybe just redirect. I will give it a try.

@jankaluza
Copy link
Member Author

Hm, but it depends how podman.io is deployed. /me goes rtm

@jankaluza
Copy link
Member Author

We've discussed this on a call and instead of this approach, we will introduce new go.podman.io subdomain served by github-pages in containers/go.podman.io project. The PR for this is here: containers/go.podman.io#1.

I'm going to close this PR without merging.

@jankaluza jankaluza closed this Aug 13, 2025
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

Successfully merging this pull request may close these issues.

2 participants