From 6d9e2d3824feb4124226c0d021e9e9cc4a2c02e7 Mon Sep 17 00:00:00 2001 From: Tuan Anh Nguyen Date: Tue, 3 Aug 2021 15:25:30 +0700 Subject: [PATCH] add agent for request to artifacthub.io/api/chartsvc --- registries/helm_hub.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/registries/helm_hub.go b/registries/helm_hub.go index e0d0032..1400559 100644 --- a/registries/helm_hub.go +++ b/registries/helm_hub.go @@ -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 } @@ -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 }