mirror of
https://github.com/helm/helm.git
synced 2026-02-27 03:51:27 -05:00
Fix helm dep list reporting wrong status
Version matching is used for checking status of subcharts. closes: #2056
This commit is contained in:
parent
570930bec0
commit
ee5dab9cb3
4 changed files with 56 additions and 16 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
|
@ -140,21 +141,41 @@ func (l *dependencyListCmd) run() error {
|
|||
}
|
||||
|
||||
func (l *dependencyListCmd) dependencyStatus(dep *chartutil.Dependency) string {
|
||||
filename := fmt.Sprintf("%s-%s.tgz", dep.Name, dep.Version)
|
||||
archive := filepath.Join(l.chartpath, "charts", filename)
|
||||
if _, err := os.Stat(archive); err == nil {
|
||||
c, err := chartutil.Load(archive)
|
||||
if err != nil {
|
||||
return "corrupt"
|
||||
}
|
||||
if c.Metadata.Name != dep.Name {
|
||||
return "misnamed"
|
||||
}
|
||||
filename := fmt.Sprintf("%s-%s.tgz", dep.Name, "*")
|
||||
archives, err := filepath.Glob(filepath.Join(l.chartpath, "charts", filename))
|
||||
if err != nil {
|
||||
return "bad pattern"
|
||||
} else if len(archives) > 1 {
|
||||
return "too many matches"
|
||||
} else if len(archives) == 1 {
|
||||
archive := archives[0]
|
||||
if _, err := os.Stat(archive); err == nil {
|
||||
c, err := chartutil.Load(archive)
|
||||
if err != nil {
|
||||
return "corrupt"
|
||||
}
|
||||
if c.Metadata.Name != dep.Name {
|
||||
return "misnamed"
|
||||
}
|
||||
|
||||
if c.Metadata.Version != dep.Version {
|
||||
return "wrong version"
|
||||
if c.Metadata.Version != dep.Version {
|
||||
constraint, err := semver.NewConstraint(dep.Version)
|
||||
if err != nil {
|
||||
return "invalid version"
|
||||
}
|
||||
|
||||
v, err := semver.NewVersion(c.Metadata.Version)
|
||||
if err != nil {
|
||||
return "invalid version"
|
||||
}
|
||||
|
||||
if constraint.Check(v) {
|
||||
return "ok"
|
||||
}
|
||||
return "wrong version"
|
||||
}
|
||||
return "ok"
|
||||
}
|
||||
return "ok"
|
||||
}
|
||||
|
||||
folder := filepath.Join(l.chartpath, "charts", dep.Name)
|
||||
|
|
@ -174,6 +195,19 @@ func (l *dependencyListCmd) dependencyStatus(dep *chartutil.Dependency) string {
|
|||
}
|
||||
|
||||
if c.Metadata.Version != dep.Version {
|
||||
constraint, err := semver.NewConstraint(dep.Version)
|
||||
if err != nil {
|
||||
return "invalid version"
|
||||
}
|
||||
|
||||
v, err := semver.NewVersion(c.Metadata.Version)
|
||||
if err != nil {
|
||||
return "invalid version"
|
||||
}
|
||||
|
||||
if constraint.Check(v) {
|
||||
return "unpacked"
|
||||
}
|
||||
return "wrong version"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,12 @@ func TestDependencyListCmd(t *testing.T) {
|
|||
expect: "WARNING: no requirements at ",
|
||||
},
|
||||
{
|
||||
name: "Requirements in chart dir",
|
||||
args: []string{"testdata/testcharts/reqtest"},
|
||||
expect: "NAME \tVERSION\tREPOSITORY \tSTATUS \nreqsubchart \t0.1.0 \thttps://example.com/charts\tunpacked\nreqsubchart2\t0.2.0 \thttps://example.com/charts\tunpacked\n",
|
||||
name: "Requirements in chart dir",
|
||||
args: []string{"testdata/testcharts/reqtest"},
|
||||
expect: "NAME \tVERSION\tREPOSITORY \tSTATUS \n" +
|
||||
"reqsubchart \t0.1.0 \thttps://example.com/charts\tunpacked\n" +
|
||||
"reqsubchart2\t0.2.0 \thttps://example.com/charts\tunpacked\n" +
|
||||
"reqsubchart3\t>=0.1.0\thttps://example.com/charts\tok \n\n",
|
||||
},
|
||||
{
|
||||
name: "Requirements in chart archive",
|
||||
|
|
|
|||
BIN
cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz
vendored
Normal file
BIN
cmd/helm/testdata/testcharts/reqtest/charts/reqsubchart3-0.2.0.tgz
vendored
Normal file
Binary file not shown.
|
|
@ -5,3 +5,6 @@ dependencies:
|
|||
- name: reqsubchart2
|
||||
version: 0.2.0
|
||||
repository: "https://example.com/charts"
|
||||
- name: reqsubchart3
|
||||
version: ">=0.1.0"
|
||||
repository: "https://example.com/charts"
|
||||
|
|
|
|||
Loading…
Reference in a new issue