Skip to content

Commit

Permalink
don't panic if no chart can be found
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMertz committed Sep 22, 2017
1 parent acd1ba9 commit 6ec6313
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chart/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func locateChartPath(name, version string) (string, error) {

version, err = helm.GetAcceptableVersion(name, version)
if err != nil {
return "", fmt.Errorf("Failed to find chart versions: %s", err)
return "", err
}

filename, _, err := dl.DownloadTo(name, version, filepath.Dir(crepo))
Expand Down
10 changes: 9 additions & 1 deletion helm/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func GetAcceptableVersion(name, constraint string) (string, error) {
return "", err
}

if len(res) == 0 {
return "", fmt.Errorf(`unable to find chart named "%s"`, name)
}

search.SortScore(res)

if constraint != "" {
Expand Down Expand Up @@ -58,7 +62,7 @@ func buildIndex() (*search.Index, error) {
func applyConstraint(version string, res []*search.Result) ([]*search.Result, error) {
constraint, err := semver.NewConstraint(version)
if err != nil {
return res, fmt.Errorf("an invalid version/constraint format: %s", err)
return res, fmt.Errorf("invalid chart version/constraint format: %s", err)
}

data := res[:0]
Expand All @@ -69,5 +73,9 @@ func applyConstraint(version string, res []*search.Result) ([]*search.Result, er
}
}

if len(data) == 0 {
return data, fmt.Errorf("unable to fulfil chart version constraint %s", version)
}

return data, nil
}

0 comments on commit 6ec6313

Please sign in to comment.