Skip to content

feat: add 'newest' policy - sort tags by image build date - #856

Open
kirgene wants to merge 1 commit into
keel-hq:masterfrom
kirgene:feature/newest-policy
Open

feat: add 'newest' policy - sort tags by image build date#856
kirgene wants to merge 1 commit into
keel-hq:masterfrom
kirgene:feature/newest-policy

Conversation

@kirgene

@kirgene kirgene commented Apr 16, 2026

Copy link
Copy Markdown

The regexp policy sorts matching tags lexicographically, which doesn't work for non-semver tags like git commit hashes - fffdf40 sorts higher than ddc5ad3 even though it was built earlier.

This adds a newest policy that filters tags by regexp (same as regexp) but sorts by the image build date from the registry config blob instead of string comparison. For each matching tag, it fetches the created timestamp from the image config blob and picks the most recently built one. Same approach as ArgoCD Image Updater's newest-build strategy.

Usage:

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

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
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.

1 participant