fix(install): use compatible version range for dependency check

Previously, the dependency check used exact version matching, which
caused false positives when a compatible version was already installed.
Now it uses `chartutil.IsCompatibleRange` to respect semantic versioning
constraints.

- Update install logic to check version compatibility instead of equality
- Adjust test case to include a version in the dependency
- Add thread-safe mutex for WaitOptions recording in fake kube client

Signed-off-by: Baptiste ROUX <arte.but.posix@gmail.com>
pull/32051/head
Baptiste ROUX 6 months ago
parent 04a77112eb
commit 919cbfaac9
No known key found for this signature in database

@ -840,7 +840,7 @@ OUTER:
if err != nil {
return err
}
if dac.Name() == rac.Name() && dac.Version() == rac.Version() {
if dac.Name() == rac.Name() && chartutil.IsCompatibleRange(rac.Version(), dac.Version()) {
continue OUTER
}
}

@ -1224,7 +1224,7 @@ func TestInstallCRDs_WaiterError(t *testing.T) {
}
func TestCheckDependencies(t *testing.T) {
dependency := chart.Dependency{Name: "hello"}
dependency := chart.Dependency{Name: "hello", Version: "0.1.0"}
mockChart := buildChart(withDependency())
assert.Nil(t, CheckDependencies(mockChart, []ci.Dependency{&dependency}))

@ -1,9 +1,3 @@
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "test" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading oci-dependent-chart from repo {{ .repoUrl }}
Deleting outdated charts
NAME: updeps
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
NAMESPACE: default

@ -19,6 +19,7 @@ package fake
import (
"io"
"sync"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -49,6 +50,7 @@ type FailingKubeClient struct {
WaitDuration time.Duration
// RecordedWaitOptions stores the WaitOptions passed to GetWaiter for testing
RecordedWaitOptions []kube.WaitOption
mu sync.Mutex
}
var _ kube.Interface = &FailingKubeClient{}
@ -160,7 +162,9 @@ func (f *FailingKubeClient) GetWaiter(ws kube.WaitStrategy) (kube.Waiter, error)
func (f *FailingKubeClient) GetWaiterWithOptions(ws kube.WaitStrategy, opts ...kube.WaitOption) (kube.Waiter, error) {
// Record the WaitOptions for testing
f.mu.Lock()
f.RecordedWaitOptions = append(f.RecordedWaitOptions, opts...)
f.mu.Unlock()
waiter, _ := f.PrintingKubeClient.GetWaiterWithOptions(ws, opts...)
printingKubeWaiter, _ := waiter.(*PrintingKubeWaiter)
return &FailingKubeWaiter{

Loading…
Cancel
Save