helm dependency update not downloading the specific version I say in Chart.yaml file
Hi !
Trying to figure out why my "helm dependency update" command not downloading the correct chart as I mention in Chart.yaml file.
The thing is , when I use the command :
helm fetch third-parties-helm-virt/cassandra --version 3.11.4+395 ; ls | grep cassan
cassandra-3.11.4+395.tgz
I get the correct version, same with "helm pull"
However, when I try to use "helm dependency update" while in my Chart.yaml file I have the exact same version , it download the latest metadata build and not the specific version I told him..
`apiVersion: v2 appVersion: 0.1.0 type: application description: test name: test version: 0.1.0
dependencies:
- name: cassandra
repository: "alias:third-parties-helm-virt"
version: "3.11.4+395"
tags:
- cassandra`
and after 'helm dependency update' command, I see :
ls charts
cassandra-3.11.4+532.tgz
it downloads version: "3.11.4+532.tgz" instead of version: "3.11.4+395.tgz"
can't figure out why its not downloading the specific version after the "+", because in pull/fetch it works perfectly and I can pull the specific version I tell him. same happens for all other charts in other repos.
also tried to use version: "=3.11.4+395"
but same behavior.
Please help :)
Output of helm version:
version.BuildInfo{Version:"v3.12.1", GitCommit:"f32a527a060157990e2aa86bf45010dfb3cc8b8d", GitTreeState:"clean", GoVersion:"go1.20.5"}
According to Semantic Versioning 2 :
Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Build metadata MUST be ignored when determining version precedence.
I write a test case to prove it, it means two versions can also Match the same target version.
func TestVersion(t *testing.T) {
c, _ := semver.NewConstraint("3.11.4+395")
v, _ := semver.NewVersion("3.11.4+395")
vv, _ := semver.NewVersion("3.11.4+532")
fmt.Println(c.Check(v), c.Check(vv))// true true
}
So, if 3.11.4+532 is before 3.11.4+395 in the helm repository index file ,helm dependency update will pull 3.11.4+532.
Why helm pull can do it as expected ? :) because command pull use = before Constraint.Check, relative code is as below:
// when customer input exact version, check whether have exact match one first
if len(version) != 0 {
for _, ver := range vs {
if version == ver.Version {
return ver, nil
}
}
}
for _, ver := range vs {
test, err := semver.NewVersion(ver.Version)
if err != nil {
continue
}
if constraint.Check(test) {
return ver, nil
}
}