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

Commit c639967

Browse files
author
Oleg Sidorov
committed
Chart repo errors are wrapped in Shipper errors fixes #152
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]>
1 parent 2f3cc10 commit c639967

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pkg/chart/repo/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (r *Repo) ResolveVersion(chartspec *shipper.Chart) (*repo.ChartVersion, err
120120
}
121121

122122
if len(versions) == 0 {
123-
return nil, repo.ErrNoChartVersion
123+
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
124124
}
125125

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

133133
vs, ok := r.index.Load().(*repo.IndexFile).Entries[chartspec.Name]
134134
if !ok {
135-
return nil, repo.ErrNoChartName
135+
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartName)
136136
}
137137
if len(vs) == 0 {
138-
return nil, repo.ErrNoChartVersion
138+
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
139139
}
140140

141141
var constraint *semver.Constraints
@@ -254,7 +254,7 @@ func (r *Repo) Fetch(chartspec *shipper.Chart) (*chart.Chart, error) {
254254
}
255255
}
256256
if chartver == nil {
257-
return nil, repo.ErrNoChartVersion
257+
return nil, shippererrors.NewChartVersionResolveError(chartspec, repo.ErrNoChartVersion)
258258
}
259259

260260
if chart, err := r.LoadCached(chartver); err == nil {

pkg/chart/repo/repo_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package repo
22

33
import (
4-
"errors"
54
"fmt"
65
"io/ioutil"
76
"net/url"
@@ -216,7 +215,7 @@ func TestResolveVersion(t *testing.T) {
216215
"simple",
217216
"=1.0.0",
218217
"",
219-
errors.New("no chart version found"),
218+
fmt.Errorf("failed to resolve chart version [name: \"simple\", version: \"=1.0.0\", repo: \"https://charts.example.com\"]: no chart version found"),
220219
},
221220
{
222221
"Existing dual version exact match",
@@ -322,15 +321,15 @@ func TestFetch(t *testing.T) {
322321
"0.0.1",
323322
"",
324323
"",
325-
fmt.Errorf("no chart name found"),
324+
fmt.Errorf("failed to resolve chart version [name: \"unknown\", version: \"0.0.1\", repo: \"https://chart.example.com\"]: no chart name found"),
326325
},
327326
{
328327
"Non-existing chart",
329328
"nginx",
330329
"10.20.30",
331330
"nginx",
332331
"",
333-
fmt.Errorf("no chart version found"),
332+
fmt.Errorf("failed to resolve chart version [name: \"nginx\", version: \"10.20.30\", repo: \"https://chart.example.com\"]: no chart version found"),
334333
},
335334
{
336335
"Fails to fetch but exists in the cache",

0 commit comments

Comments
 (0)