0

I've read that wondeful topic but there are no answer for some questions:

1. What is the difference beetween:

  • a) ^0 and ^0.*.0
  • b) ^0.0 and ^0.*.0
  • c) ^0.0.0 and ^0.*.0
  • d) ^0 and ^0.* ...

2. Let say ~1.2 means 1.2.0 <= v < 1.3.0.

Is there any guarantee that maximun version will be taken or might be taken any version from the range ?

3. What is the difference between * and x ?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

1

As you may read about semantic veersioning (SemVer), the numbers are specified as: MAJOR.MINOR.PATCH.

Now, from Helm's documentation about the caret ^:

The caret (^) comparison operator is for major level changes once a stable (1.0.0) release has occurred. Prior to a 1.0.0 release the minor versions acts as the API stability level. This is useful when comparisons of API versions as a major change is API breaking. For example,

  • ^1.2.3 is equivalent to >= 1.2.3, < 2.0.0
  • ^1.2.x is equivalent to >= 1.2.0, < 2.0.0
  • ^2.x is equivalent to >= 2.0.0, < 3
  • ^0.2 is equivalent to >=0.2.0 <0.3.0
  • ^0.0 is equivalent to >=0.0.0 <0.1.0
  • ^0 is equivalent to >=0.0.0 <1.0.0

In short, the caret (^) locks your major version number, so in all of ^1, ^1.0.0 the 1 would be locked, and it won't match any version that has a major release number >1.

And about the * and x, from Helm's documentation

The x, X, and * characters can be used as a wildcard character. This works for all comparison operators. When used on the = operator it falls back to the patch level comparison

Which means, *, x and X are all the same. All of them are wildcards and they match any number.

  • 1.2.x is equivalent to >= 1.2.0, < 1.3.0
  • >= 1.2.x is equivalent to >= 1.2.0
  • <= 2.x is equivalent to < 3
  • * is equivalent to >= 0.0.0

And about the tilde (~), also refer to the same page in the documentation:

The tilde (~) comparison operator is for patch level ranges when a minor version is specified and major level changes when the minor number is missing. For example,

  • ~1.2.3 is equivalent to >= 1.2.3, < 1.3.0
  • ~2.3 is equivalent to >= 2.3, < 2.4
  • ~1.2.x is equivalent to >= 1.2.0, < 1.3.0

See more:

Fcmam5
  • 4,888
  • 1
  • 16
  • 33
  • you didn't answer for some questions: Let's say we have 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 in the repo And I use ^1. Is it guaranteed that 1.1.0 will be taken ? Most people rely in it but I don't see any phrase in documentation about it – gstackoverflow Mar 06 '23 at 07:35
  • From their source code, it appears that they [fetch first element from the sorted repo tags list](https://github.com/helm/helm/blob/main/internal/resolver/resolver.go#L177), and the sort is [ascending](https://github.com/helm/helm/blob/e007c900ce5f2233c8583565d5ba1b0433b1a213/pkg/registry/client.go#L594), see [go/semver](https://github.com/Masterminds/semver#working-with-prerelease-versions) package, and [this snippets](https://go.dev/play/p/BZNoALlaiDf) replicates that logic. So yes, 1.1.0 will be taken – Fcmam5 Mar 06 '23 at 09:59
  • I prefer to rely on documentation (contract) because implementation could be changed. – gstackoverflow Mar 06 '23 at 12:33