Skip to content

Commit 869a9df

Browse files
committed
helm: return ErrExternal when loading index fails
Loading index can fail due to network error. Return ErrExternal typed error for it. Signed-off-by: Sunny <[email protected]>
1 parent 8018b45 commit 869a9df

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/helm/repository/chart_repository.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func newChartRepository() *ChartRepository {
156156
// to be a semver.Constraints compatible string. If version is empty, the latest
157157
// stable version will be returned and prerelease versions will be ignored.
158158
func (r *ChartRepository) GetChartVersion(name, ver string) (*repo.ChartVersion, error) {
159+
// See if we already have the index in cache or try to load it.
160+
if err := r.StrategicallyLoadIndex(); err != nil {
161+
return nil, &ErrExternal{Err: err}
162+
}
163+
159164
cv, err := r.getChartVersion(name, ver)
160165
if err != nil {
161166
return nil, &ErrReference{Err: err}
@@ -164,11 +169,6 @@ func (r *ChartRepository) GetChartVersion(name, ver string) (*repo.ChartVersion,
164169
}
165170

166171
func (r *ChartRepository) getChartVersion(name, ver string) (*repo.ChartVersion, error) {
167-
// See if we already have the index in cache or try to load it.
168-
if err := r.StrategicallyLoadIndex(); err != nil {
169-
return nil, err
170-
}
171-
172172
r.RLock()
173173
defer r.RUnlock()
174174

0 commit comments

Comments
 (0)