Skip to content

Commit

Permalink
chore: HTTPGetter add default timeout
Browse files Browse the repository at this point in the history
Signed-off-by: 0xff-dev <stevenshuang521@gmail.com>

Co-authored-by: bjwswang <bjwswang@gmail.com>
Co-authored-by: Abirdcfly <fp544037857@gmail.com>
  • Loading branch information
3 people committed Aug 11, 2023
1 parent 14d3636 commit 2011a31
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/getter/getter.go
Expand Up @@ -172,9 +172,21 @@ func (p Providers) ByScheme(scheme string) (Getter, error) {
return nil, errors.Errorf("scheme %q not supported", scheme)
}

const (
// The cost timeout references curl's default connection timeout.
// https://github.com/curl/curl/blob/master/lib/connect.h#L40C21-L40C21
// The helm commands are usually executed manually. Considering the acceptable waiting time, we reduced the entire request time to 120s.
DefaultHTTPTimeout = 120
)

var defaultOptions = []Option{WithTimeout(time.Second * DefaultHTTPTimeout)}

var httpProvider = Provider{
Schemes: []string{"http", "https"},
New: NewHTTPGetter,
New: func(options ...Option) (Getter, error) {
options = append(options, defaultOptions...)
return NewHTTPGetter(options...)
},
}

var ociProvider = Provider{
Expand Down

0 comments on commit 2011a31

Please sign in to comment.