notifier: add a timeout on the http client

This commit is contained in:
Quentin Machu 2016-02-22 16:38:16 -05:00 committed by Jimmy Zelinskie
parent 274a1620a5
commit 904ce6004f

View File

@ -25,6 +25,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"time"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -33,6 +34,8 @@ import (
"github.com/coreos/clair/notifier" "github.com/coreos/clair/notifier"
) )
const timeout = 5 * time.Second
// A WebhookNotifier dispatches notifications to a webhook endpoint. // A WebhookNotifier dispatches notifications to a webhook endpoint.
type WebhookNotifier struct { type WebhookNotifier struct {
endpoint string endpoint string
@ -89,6 +92,7 @@ func (h *WebhookNotifier) Configure(config *config.NotifierConfig) (bool, error)
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: tlsConfig, TLSClientConfig: tlsConfig,
}, },
Timeout: timeout,
} }
return true, nil return true, nil
} }