Chore: Fix staticcheck issues (#28860)

* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Undo changes

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix test

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix test

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-11-05 13:07:06 +01:00
committed by GitHub
parent 7897c6b7d5
commit 3d3a7cbba8
41 changed files with 125 additions and 124 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ func (auth *AuthProxy) IsAllowedIP() (bool, *Error) {
}
err := fmt.Errorf(
"Request for user (%s) from %s is not from the authentication proxy", auth.header,
"request for user (%s) from %s is not from the authentication proxy", auth.header,
sourceIP,
)
+6 -4
View File
@@ -33,11 +33,11 @@ func Logger() macaron.Handler {
rw := res.(macaron.ResponseWriter)
c.Next()
timeTakenMs := time.Since(start) / time.Millisecond
timeTaken := time.Since(start) / time.Millisecond
if timer, ok := c.Data["perfmon.timer"]; ok {
timerTyped := timer.(prometheus.Summary)
timerTyped.Observe(float64(timeTakenMs))
timerTyped.Observe(float64(timeTaken))
}
status := rw.Status()
@@ -50,9 +50,11 @@ func Logger() macaron.Handler {
if ctx, ok := c.Data["ctx"]; ok {
ctxTyped := ctx.(*models.ReqContext)
if status == 500 {
ctxTyped.Logger.Error("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status, "remote_addr", c.RemoteAddr(), "time_ms", int64(timeTakenMs), "size", rw.Size(), "referer", req.Referer())
ctxTyped.Logger.Error("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status,
"remote_addr", c.RemoteAddr(), "time_ms", int64(timeTaken), "size", rw.Size(), "referer", req.Referer())
} else {
ctxTyped.Logger.Info("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status, "remote_addr", c.RemoteAddr(), "time_ms", int64(timeTakenMs), "size", rw.Size(), "referer", req.Referer())
ctxTyped.Logger.Info("Request Completed", "method", req.Method, "path", req.URL.Path, "status", status,
"remote_addr", c.RemoteAddr(), "time_ms", int64(timeTaken), "size", rw.Size(), "referer", req.Referer())
}
}
}
+4 -4
View File
@@ -5,13 +5,13 @@ import (
"net/http"
"net/http/httptest"
. "github.com/smartystreets/goconvey/convey"
"gopkg.in/macaron.v1"
"github.com/grafana/grafana/pkg/infra/remotecache"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/auth"
"github.com/grafana/grafana/pkg/setting"
"github.com/smartystreets/goconvey/convey"
)
type scenarioContext struct {
@@ -49,7 +49,7 @@ func (sc *scenarioContext) withAuthorizationHeader(authHeader string) *scenarioC
func (sc *scenarioContext) fakeReq(method, url string) *scenarioContext {
sc.resp = httptest.NewRecorder()
req, err := http.NewRequest(method, url, nil)
So(err, ShouldBeNil)
convey.So(err, convey.ShouldBeNil)
sc.req = req
return sc
@@ -63,7 +63,7 @@ func (sc *scenarioContext) fakeReqWithParams(method, url string, queryParams map
q.Add(k, v)
}
req.URL.RawQuery = q.Encode()
So(err, ShouldBeNil)
convey.So(err, convey.ShouldBeNil)
sc.req = req
return sc
@@ -94,7 +94,7 @@ func (sc *scenarioContext) exec() {
if sc.resp.Header().Get("Content-Type") == "application/json; charset=UTF-8" {
err := json.NewDecoder(sc.resp.Body).Decode(&sc.respJson)
So(err, ShouldBeNil)
convey.So(err, convey.ShouldBeNil)
}
}