Skip to content

Commit

Permalink
Add extra error info when downloading remote charts
Browse files Browse the repository at this point in the history
Refers to: #3160

Signed-off-by: Xavi Garcia <[email protected]>
  • Loading branch information
0xavi0 committed Feb 18, 2025
1 parent e6df5eb commit 5952a0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion integrationtests/cli/apply/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func testHelmRepo(path, port string) {
})
Expect(err).To(HaveOccurred())
return err.Error()
}).Should(Equal("error parsing regexp: missing closing ): `a(b`"))
}).Should(Equal("repo= chart=http://localhost:3000/config-chart-0.1.0.tgz version=: error parsing regexp: missing closing ): `a(b`"))

Check failure on line 173 in integrationtests/cli/apply/helm_test.go

View workflow job for this annotation

GitHub Actions / unit-test

It 02/18/25 10:24:34.685
})
})

Expand Down
14 changes: 12 additions & 2 deletions internal/bundlereader/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ func addRemoteCharts(directories []directory, base string, charts []*fleet.HelmO
if _, err := os.Stat(filepath.Join(base, chart.Chart)); os.IsNotExist(err) || chart.Repo != "" {
shouldAddAuthToRequest, err := shouldAddAuthToRequest(helmRepoURLRegex, chart.Repo, chart.Chart)
if err != nil {
return nil, err
return nil, downloadChartError(*chart, err)
}
if !shouldAddAuthToRequest {
auth = Auth{}
}

chartURL, err := chartURL(*chart, auth)
if err != nil {
return nil, err
return nil, downloadChartError(*chart, err)
}

directories = append(directories, directory{
Expand All @@ -178,6 +178,16 @@ func addRemoteCharts(directories []directory, base string, charts []*fleet.HelmO
return directories, nil
}

func downloadChartError(c fleet.HelmOptions, e error) error {
return fmt.Errorf(
"repo=%s chart=%s version=%s: %w",
c.Repo,
c.Chart,
c.Version,
e,
)
}

func shouldAddAuthToRequest(helmRepoURLRegex, repo, chart string) (bool, error) {
if helmRepoURLRegex == "" {
return true, nil
Expand Down

0 comments on commit 5952a0a

Please sign in to comment.