mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
all: gometalinter (#843)
* kubernetes/reverse: remove deadcode * deadcode in errors and kubernetes removed * unnecessary conversion * constants * proxy: time.Since() * simplications * static check * Disable test/external_test
This commit is contained in:
@@ -69,7 +69,7 @@ type (
|
||||
func Scrape(t *testing.T, url string) []*MetricFamily {
|
||||
mfChan := make(chan *dto.MetricFamily, 1024)
|
||||
|
||||
go fetchMetricFamilies(t, url, mfChan)
|
||||
go fetchMetricFamilies(url, mfChan)
|
||||
|
||||
result := []*MetricFamily{}
|
||||
for mf := range mfChan {
|
||||
@@ -177,20 +177,20 @@ func makeBuckets(m *dto.Metric) map[string]string {
|
||||
return result
|
||||
}
|
||||
|
||||
func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily) {
|
||||
func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) {
|
||||
defer close(ch)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("creating GET request for URL %q failed: %s", url, err)
|
||||
return
|
||||
}
|
||||
req.Header.Add("Accept", acceptHeader)
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("executing GET request for URL %q failed: %s", url, err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("GET request for URL %q returned HTTP status %s", url, resp.Status)
|
||||
return
|
||||
}
|
||||
|
||||
mediatype, params, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
||||
@@ -203,7 +203,7 @@ func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily)
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
t.Fatalf("reading metric family protocol buffer failed: %s", err)
|
||||
return
|
||||
}
|
||||
ch <- mf
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily)
|
||||
var parser expfmt.TextParser
|
||||
metricFamilies, err := parser.TextToMetricFamilies(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal("reading text format failed:", err)
|
||||
return
|
||||
}
|
||||
for _, mf := range metricFamilies {
|
||||
ch <- mf
|
||||
|
||||
Reference in New Issue
Block a user