Skip to content

Commit

Permalink
add agent for request to artifacthub.io/api/chartsvc
Browse files Browse the repository at this point in the history
  • Loading branch information
tuananhnguyen-ct authored and sstarcher committed Aug 3, 2021
1 parent 409058f commit 6d9e2d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions registries/helm_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ func (h HelmRegistries) useHelmHub(chart string) string {
}

func findChart(chart string) (string, error) {
url := fmt.Sprintf("https://hub.helm.sh/api/chartsvc/v1/charts/search?q=%s", chart)
resp, err := http.Get(url)
url := fmt.Sprintf("https://artifacthub.io/api/chartsvc/v1/charts/search?q=%s", chart)

client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
req.Header.Set("User-Agent", "Go-http-client/1.1")
resp, err := client.Do(req)

if err != nil {
return "", err
}
Expand All @@ -81,7 +86,7 @@ func findChart(chart string) (string, error) {

func getChartVersions(chart string) ([]string, error) {
url := fmt.Sprintf("https://artifacthub.io/api/v1/packages/helm/%s", chart)
resp, err := http.Get(url)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6d9e2d3

Please sign in to comment.