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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a semver-transformer annotation to assist in converting sloppy tags to semvers #413

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djeebus
Copy link

@djeebus djeebus commented Apr 6, 2022

This allows argocd-image-updater to support finding the latest tag even when they don't really follow semver exactly. Some good examples of this:

  • plexinc/pms-docker example: 1.25.7.5604-980a13e02 (semver requires at most 3 numeric sections, i.e. 1.2.3, not 1.2.3.4)
  • fireflyiii/core example: version-5.6.16 (leading chars should be v, not version-)

This PR would let us set the regexp to be (in pms-docker's case) ^(\d+\.\d+\.\d+)\.\d+-.*$', or just (\d+\.\d+\.\d+). The code checks for groups, and if none are found, assumes that the full tag is the semver (same as current behavior). If a capture group is found, however, then it parses the capture group as a semver, rather than the full thing.

A few other small things added:

  • the test command now supports --semver-transformer
  • if test can't parse --semver-transformer or --allow-tags, it exits with an error message
  • if update can't parse --semver-transformer or --allow-tags, it skips the image with an error message, making it more obvious that you've configured something poorly
  • MatchFuncRegexp now creates a closure, removing the need for a separate MatchArgs interface{} on the VersionConstraint struct
  • removed ConstraintMatchMode and its associated consts in pkg/image/version.go`, as they were completely unused.
  • split up some of the matching logic in pkg/registry/registry.go so it is more clear why an image is skipped when tracing.

Let me know if any of that above list should be rolled back. Some of it was just to clean up what I was looking at, maybe a bad habit of mine 馃槼

(This supercedes #407)

this lets us coerce tags from almost-semver formats to actual semver.
@djeebus
Copy link
Author

djeebus commented Apr 6, 2022

sorry, looks like I missed a code path. let me work on this a bit and see if I can slim it down some

@jannfis
Copy link
Contributor

jannfis commented Apr 12, 2022

Thanks for this PR @djeebus - looking forward to get this merged!

Some of it was just to clean up what I was looking at, maybe a bad habit of mine

This is actually much appreciated, as long as it doesn't refactor too much unrelated things :)

@djeebus
Copy link
Author

djeebus commented Apr 28, 2022

Two things have stopped me from getting this done :(

  1. found out that there was a major code path missing - I need to use the semver-transformer in order to transform the current image in order to compare it against new images. That proved to be a little tedious, I'm headed into code that I haven't seen yet, so it's gonna take some more time to sort that out.
  2. Life :(

Once I get #2 sorted out, I'll get back to #1. Thanks for understanding!

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.

None yet

2 participants