Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Chart repo errors are wrapped in Shipper errors fixes #152
Browse files Browse the repository at this point in the history
This change is aiming to turn helm library errors into Shipper errors so
the responsible caller gets an idea if the error should be retried.

Signed-off-by: Oleg Sidorov <[email protected]>
  • Loading branch information
Oleg Sidorov committed Aug 19, 2019
1 parent 2f3cc10 commit c639967
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/chart/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *Repo) ResolveVersion(chartspec *shipper.Chart) (*repo.ChartVersion, err
}

if len(versions) == 0 {
return nil, repo.ErrNoChartVersion
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
}

return versions[0], nil
Expand All @@ -132,10 +132,10 @@ func (r *Repo) FetchChartVersions(chartspec *shipper.Chart) (repo.ChartVersions,

vs, ok := r.index.Load().(*repo.IndexFile).Entries[chartspec.Name]
if !ok {
return nil, repo.ErrNoChartName
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartName)
}
if len(vs) == 0 {
return nil, repo.ErrNoChartVersion
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
}

var constraint *semver.Constraints
Expand Down Expand Up @@ -254,7 +254,7 @@ func (r *Repo) Fetch(chartspec *shipper.Chart) (*chart.Chart, error) {
}
}
if chartver == nil {
return nil, repo.ErrNoChartVersion
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
}

if chart, err := r.LoadCached(chartver); err == nil {
Expand Down
7 changes: 3 additions & 4 deletions pkg/chart/repo/repo_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package repo

import (
"errors"
"fmt"
"io/ioutil"
"net/url"
Expand Down Expand Up @@ -216,7 +215,7 @@ func TestResolveVersion(t *testing.T) {
"simple",
"=1.0.0",
"",
errors.New("no chart version found"),
fmt.Errorf("failed to resolve chart version [name: \"simple\", version: \"=1.0.0\", repo: \"https://charts.example.com\"]: no chart version found"),
},
{
"Existing dual version exact match",
Expand Down Expand Up @@ -322,15 +321,15 @@ func TestFetch(t *testing.T) {
"0.0.1",
"",
"",
fmt.Errorf("no chart name found"),
fmt.Errorf("failed to resolve chart version [name: \"unknown\", version: \"0.0.1\", repo: \"https://chart.example.com\"]: no chart name found"),
},
{
"Non-existing chart",
"nginx",
"10.20.30",
"nginx",
"",
fmt.Errorf("no chart version found"),
fmt.Errorf("failed to resolve chart version [name: \"nginx\", version: \"10.20.30\", repo: \"https://chart.example.com\"]: no chart version found"),
},
{
"Fails to fetch but exists in the cache",
Expand Down

0 comments on commit c639967

Please sign in to comment.