-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Enhance git tagger to tag with latest git tag or other formats #407
Comments
Happy to help someone design and implement this, it would be a good first issue to tackle. |
@r2d4 I'm interested in taking this on, but would like some clarification please.
|
Awesome! Let me give you some background. Skaffold has a few different interfaces: builders, taggers, and deployers. Taggers are responsible for taking the build and artifact metadata, and generating a docker image tag from it. That tag will then be used to tag the image in the repository (or daemon) and as part of the kubernetes deployment. There are different "taggers" today:
All of the relevant code is in this file https://github.com/GoogleContainerTools/skaffold/blob/master/pkg/skaffold/build/tag/git_commit.go The current implementation generates a tag with the git commit, shortened to 6 characters. If the repository state is "dirty" (there are uncommited changes), then it will append the checksum the output of git diff to the tag (so that there is a new tag if there is new code). The proposed additions would be modifying this struct To look something more like type GitTagger struct {
UseFullCommit bool `yaml:useFullCommit,omitempty`
UseDescribe bool `yaml:useDescribe,omitempty`
...
} If UseFullCommit is set, it shouldn't trim the commit sha256 and should use the whole commit. If UseDescribe is set, it should instead generate a tag with the output of @dlorenc might have some other thoughts on what he would want toggled by this. The goal of this feature is to enable users to generate more semantic docker image tags from their git repository, without having to resort to figuring out these tags themselves and passing it into skaffold as a custom tag. |
@stepharr Github won't let me assign this issue to you as a non-collaborator, so I'll assign it to myself so nobody else picks it up |
We have a simple homegrown script that looks like this: WORKING_SUFFIX=$(if git status --porcelain | grep -qE '^(?:[^?][^ ]|[^ ][^?])\s'; then echo "-WIP"; else echo ""; fi)
BRANCH_PREFIX=$(git rev-parse --abbrev-ref HEAD)
echo "${BRANCH_PREFIX//\//-}-$(git rev-parse --short HEAD)$WORKING_SUFFIX" Having branch prefix allows you to: I'd really like to have this kind of formatting as an option. |
Also, another strategy that is quite different, but I think it makes a lot of sense is one that LinuxKit uses. It computes (sub-)tree hash and uses that. So if you see a LinuxKit image The implementation lives in |
I'm not sure about the context, but in LinuxKit we default the image tag to the git tree hashs, something like:
This is basically the content hash of the directory. It has the advantage over the git commit hash that we only need to retag on every commit, just when the content of the directory changes. The downside is that all the dependencies for a image have to be in one directory. Since it is hard to get the source code revision from the git tree hash, we add the git commit hash to a image label, ie we pass We append For releases we tag images with the git tree hash and a version tag, such as For development, we allow overwriting the tag as well and there are some short cuts to add HTH |
@rn Yes it is a good solution and it is for shure to have. |
How we will handle directory based hashes with future features like moby/moby#37129? |
Can we use something |
@r2d4 I'm going to work on this. Do you think it needs a design proposal? |
Just nit-picking: git still uses sha-1 |
The git tagger currently doesnt take any parameters but should take some to configure how we resolve image tags from git history. Some options I'd like to see, not sure if they should be exposed as bool parameters or a string enum.
The text was updated successfully, but these errors were encountered: