sprig icon indicating copy to clipboard operation
sprig copied to clipboard

semverCompare: Unable to compare complex version string

Open L3Nerd opened this issue 4 years ago • 1 comments

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

L3Nerd avatar Aug 02 '21 14:08 L3Nerd

Hi. I forked the project and started to revive it. Your suggestion is cool. Can you create copy this issue to the my fork?

nikgalushko avatar Nov 13 '21 14:11 nikgalushko