-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Feature Request: Autodiscover should be smarter when it decides which versionfilter to use #977
Comments
A few notes:
|
I am adding a bit of context on why I opened this issue. I am also facing this problem in the context of updatemonitor where I want to monitor specific prerelease. What do you think to try multiple regex such
and if none matching then return versionfilter of type latest or semver |
This regexp should be enough to match all these cases: Note: be aware the dots in your regexp patterns match every character, not only |
More I think about this issue and less I think it's doable in a generic way... :( The problem is depending on the API it doesn't sort the values the same way While ghcr.io will return the list sorted by published time such as So the way to uniform this is to use the semantic versioning approach. Let's take the docker image tag "node:9-alpine" We could generate the following manifest
or
Or we just don't care about semver metadata and only return the latest version using semantic versioning |
Well I think the root cause of my problem is that the library we use to filter version using sementic versioning do not allow to preserve prerelease information Masterminds/semver#184 So for example for the docker image Maybe I could a parameter to the versionfilter to mention that we want to preserve some fields
The goal is to build a list of versions that only contains prerelease information matching "jdk11" and then we apply the pattern ">=1.0.0" Maybe the solution must come from the upstream library |
I am sharing this document here |
I have been scratching my head about how to retrieve a docker image tag using a semver prerelease information. The problem is if we have both a version like "19.0.0-alpine" and "19.0.0" and we try to know which one is the latest, then "19.0.0" win always win. This is not what I am looking for. If I use a docker image tag with "alpine" in the tag then there is probably a reason. Second thing that bother me in the context of docker image tag, is that it can be really difficult to make the difference between "20221115" and "2". In my test case I have many images like "quay.io/calico/node" The best solution I could think about is to provide
Where the goal is to retrieve the docker image tag "node:19-alpine" |
That is correct as per the semver specification: https://semver.org/#spec-item-11.
=> Problem is that you want to use the "semver" library for the "sorting" part when using a regex because you have different sorting based on the different repositories. I understand the root cause since you explained it to me in 1:1, but it still not a solution trying to use edge cases of semver to solve that issue.
That snippet should be:
because => again, the issue would be with the sorting algorithm. That would be a concern outside the "autodiscovery": it is a concern with the docker image resource and not an easy one; WDYT about fixing the root issue at the "versionFilter" level when it is a regex? and/or the time based sorting? I know it is not easy topic, but it need to be correctly done to not create false expectations for users. |
Something that could eventually help us around sorting: https://yourbasic.org/golang/how-to-sort-in-go/#sort-with-custom-comparator |
First of fall this problem is indeed difficult and I have been scratching my head around this problem for quite long time now :/ So regarding "19.0.0-alpine" is a valid a semantic version where "--alpine" is the prerelease information
Unfortunately, the following example is not option as it doesn't return reliable results. That was one of my first attempts to solve this problem.
That being said using the the semver regex, https://github.com/Masterminds/semver/blob/master/version.go#L42 the masterminds/semver library is able to parse it and convert this version to My suggestion out of the following versions:
Is to first pre-filter tags using regex for example using "^(\d*).(\d*).(\d*)-alpine$"
If we apply the same technique to a more restrive rule such as ["17-alpine","18-alpine"] the lib parse them and consider them as ["17.0.0-alpine","18.0.0-alpine"] and then in the back we retrieve the original value. We already use this approach to filter github release. For example the Golang project publish a new major release such as I don't think there is another way that first pre-filtering information before passing them to the versionFilter engine. |
It is not because That is the reason why trying to use semver for things that are NOT semvers by exploiting edge cases of the implementation (the semver library used under the hood) is a dangerous path to walk. Particularly in a tool such as updatecli.
Maybe it solves your problem on short term for your use case. But it is definitively a lie to the end user. At least add a LOT of INFO line to tell the user how it is sorted. The risk of confusion between
the prefiltering is a good first step. I wonder if it should be exposed to the user or not. WDYT about doing it as an implementation detail (not specified by the end user)? I wonder if we could not do the sorting ourselves after the prefilter (based on your idea) |
I couldn't definitely use it as an implementation detail for now, so not exposed via the manifest. To delay the decision for later but in the end I think it will be useful for other resources too. So it could make sense to move from Dockerimage to versionfilter.
Hence the purpose of pref The purpose of the autodiscovery is to catch as much as cases as possible but it's impossible to cover all of them, hence the importance to be able to optout depending on rules, such as docker image, docker-compose file,etc...
|
I don't think it will be possible to automatically detect the right versionfilter to use. https://www.updatecli.io/docs/plugins/autodiscovery/golang/ I am planning to update the other autodiscovery plugins with that approach. |
Closing for now, the situation already improved |
Is your feature request related to a problem?
Right now, we always use the semver versionfilter in the context of autodiscovery.
I would like Updatecli to be smart an try multiple constraint
Solution you'd like
I would like Updatecli to respect the following versions
1.0.0 -> Should return a semver with three fields
1.0 -> should return a regex with two fields such as
^(\d).(\d)$
1 -> should return a regex with one field such as
^(\d)$
1.0.0-alpha -> Should return a regex such as
^(\d).(\d).(\d)-alpha
Alternatives you've considered
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: