mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(libhelm): allow passing optional env and http client [EE-5252] (#8758)
This commit is contained in:
parent
a7474188b9
commit
7a8a20e0cc
29 changed files with 161 additions and 52 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
const invalidChartRepo = "%q is not a valid chart repository or cannot be reached"
|
||||
|
||||
func ValidateHelmRepositoryURL(repoUrl string) error {
|
||||
func ValidateHelmRepositoryURL(repoUrl string, client *http.Client) error {
|
||||
if repoUrl == "" {
|
||||
return errors.New("URL is required")
|
||||
}
|
||||
|
@ -29,9 +29,12 @@ func ValidateHelmRepositoryURL(repoUrl string) error {
|
|||
|
||||
url.Path = path.Join(url.Path, "index.yaml")
|
||||
|
||||
var client = &http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
if client == nil {
|
||||
client = &http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
}
|
||||
}
|
||||
|
||||
response, err := client.Head(url.String())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, invalidChartRepo, repoUrl)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue