feat: add 'newest' policy - sort tags by image build date - #856
Open
kirgene wants to merge 1 commit into
Open
Conversation
Add a new 'newest' policy that filters tags by regexp and sorts them
by the image creation timestamp from the registry, rather than by
lexicographic string comparison.
This solves the problem where non-semver tags (like git commit hashes)
cannot be meaningfully sorted by string value. The newest policy
fetches the image config blob from the registry to read the 'created'
timestamp, then picks the most recently built image.
Usage examples:
keel.sh/policy: "newest:^[a-f0-9]{7}$" # git short hashes
keel.sh/policy: "newest:^build-.*" # build-prefixed tags
keel.sh/policy: "newest:.*" # any tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
regexppolicy sorts matching tags lexicographically, which doesn't work for non-semver tags like git commit hashes -fffdf40sorts higher thanddc5ad3even though it was built earlier.This adds a
newestpolicy that filters tags by regexp (same asregexp) but sorts by the image build date from the registry config blob instead of string comparison. For each matching tag, it fetches thecreatedtimestamp from the image config blob and picks the most recently built one. Same approach as ArgoCD Image Updater'snewest-buildstrategy.Usage: