sprig
sprig copied to clipboard
semverCompare: Unable to compare complex version string
I just stumbled over following problem with semverCompare.
Summary
If a have a short version string (only major and minor) and the other operator is a very long, but valid, version with a couple of metadata and per-release information, the comparison returns false, where it should return true.
If the other operator has at least pre-release information, the result of the comparison is true, see my examples below.
Test Template
VERSION: {{ .Capabilities.KubeVersion.Version }}
VERSION >= 1.15 == {{ semverCompare ">=1.15" .Capabilities.KubeVersion.Version }}
VERSION >= 1.18.0-beta.1 == {{ semverCompare ">=1.18.0-beta.1" .Capabilities.KubeVersion.Version }}
Output
VERSION: v1.19.2-1023+4cad5caeae67c3-dirty
VERSION >= 1.15 == false
VERSION >= 1.18.0-beta.1 == true
Expected Output
VERSION: v1.19.2-1023+4cad5caeae67c3-dirty
VERSION >= 1.15 == true
VERSION >= 1.18.0-beta.1 == true
Hi. I forked the project and started to revive it. Your suggestion is cool. Can you create copy this issue to the my fork?