forked from coop-cloud/abra
refactor: use web module timeout everywhere
This commit is contained in:
parent
e68c7fc71c
commit
a3e02540f6
@ -142,7 +142,7 @@ func (a ByAppName) Less(i, j int) bool {
|
||||
var appsCatalogueURL = "https://apps.coopcloud.tech"
|
||||
|
||||
func appsCatalogueFSIsLatest() (bool, error) {
|
||||
httpClient := &http.Client{Timeout: 5 * time.Second}
|
||||
httpClient := &http.Client{Timeout: web.Timeout}
|
||||
res, err := httpClient.Head(appsCatalogueURL)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/web"
|
||||
"github.com/docker/distribution/reference"
|
||||
@ -41,7 +40,7 @@ func getRegv2Token(image reference.Named) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
client := &http.Client{Timeout: web.Timeout}
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -97,7 +96,7 @@ func GetTagDigest(image reference.Named) (string, error) {
|
||||
"Authorization": []string{fmt.Sprintf("Bearer %s", token)},
|
||||
}
|
||||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
client := &http.Client{Timeout: web.Timeout}
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -6,9 +6,13 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Timeout is the time it takes before a web request bails out waiting for a
|
||||
// request.
|
||||
const Timeout = 10 * time.Second
|
||||
|
||||
// ReadJSON reads JSON and parses it into your chosen interface pointer
|
||||
func ReadJSON(url string, target interface{}) error {
|
||||
httpClient := &http.Client{Timeout: 5 * time.Second}
|
||||
httpClient := &http.Client{Timeout: Timeout}
|
||||
res, err := httpClient.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user