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

git tag default is incorrect #3836

Open
deitch opened this issue Oct 7, 2022 · 2 comments
Open

git tag default is incorrect #3836

deitch opened this issue Oct 7, 2022 · 2 comments

Comments

@deitch
Copy link
Collaborator

deitch commented Oct 7, 2022

Description

Every container image built by lkt pkg build adds a few standard tags in the config, including git commit, etc.

One of those tags is org.opencontainers.image.source. lkt pkg build uses the following logic:

  1. If the source is provided in build.yaml, use that
  2. If not, fall back to https://github.com/linuxkit/linuxkit

Given how much lkt pkg build determines from the git dir (tree hash, commit, tag if any, etc.), it should be able to determine the source as well as the commit, and not just fall back to https://github.com/linuxkit/linuxkit every time.

The problem is, how do you determine it? git remote doesn't quite give it to you, as it includes not just the canonical URL, but the access mode. Should it be git+ssh? Or maybe git@github.com:foo/bar.git? Or the (more canonical) https://github.com/foo/bar? Or https://github.com/foo/bar.git? How would we determine it? Rules for github conversions may not be the same as for gitlab as for some private git repo as for Atlassian bitbucket as, etc.

Further, people can use their own aliases for the hostname to change logins for various repos, so git@user.github.com:foo/bar might actually be the exact same repo as git@github.com:foo/bar, which is https://github.com/foo/bar.

How would we resolve it?

I am looking for sane approaches that don't cause too much surprise. My current leanings are towards:

  1. If it is in build.yaml, take it as is (current override)
  2. If not, read the remotes, select the right remote:
    1. Only one remote? Use that; else
    2. Two or more repos and one is upstream? Use that; else
    3. Two or more repos and one is origin? Use that; else
    4. Default to current linuxkit one

As for interpreting the URL:

  1. http URL? use it as is
  2. git URL?
    • If the hostname ends in github.com, canonicalize it to https
    • If it does not, fall back to default

I know this doesn't cover everything, but seems reasonable to start. It should be a reasonable improvement.

@eriknordmark
Copy link
Contributor

Is the commit hash from the actual source even when it ends up setting .source to https://github.com/linuxkit/linuxkit?

@deitch
Copy link
Collaborator Author

deitch commented Oct 20, 2022

Yes it is. The logic for getting the hash works correctly. The logic for getting the repo canonical address is much more limited for the reasons listed above.

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

2 participants