Skip to content

Commit

Permalink
Merge pull request #1735 from owncloud/proxy-resolve-linter
Browse files Browse the repository at this point in the history
resolve linter issues
  • Loading branch information
butonic committed Feb 26, 2021
2 parents 4ec4dd5 + cfcd4b5 commit a2e1e9f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 49 deletions.
33 changes: 0 additions & 33 deletions proxy/.golangci.yaml

This file was deleted.

22 changes: 14 additions & 8 deletions proxy/pkg/metrics/metrics.go
Expand Up @@ -49,21 +49,27 @@ func New() *Metrics {
}, []string{"versions"}),
}

prometheus.Register(
mustNotFail(prometheus.Register(
m.Counter,
)
))

prometheus.Register(
mustNotFail(prometheus.Register(
m.Latency,
)
))

prometheus.Register(
mustNotFail(prometheus.Register(
m.Duration,
)
))

prometheus.Register(
mustNotFail(prometheus.Register(
m.BuildInfo,
)
))

return m
}

func mustNotFail(err error) {
if err != nil {
panic(err)
}
}
2 changes: 1 addition & 1 deletion proxy/pkg/middleware/oidc_auth.go
Expand Up @@ -112,7 +112,7 @@ func (m oidcAuth) getClaims(token string, req *http.Request) (claims oidc.Standa
return
}

var ok = false
var ok bool
if claims, ok = hit.V.(oidc.StandardClaims); !ok {
status = http.StatusInternalServerError
return
Expand Down
9 changes: 5 additions & 4 deletions proxy/pkg/proxy/proxy_integration_test.go
Expand Up @@ -136,16 +136,17 @@ func TestProxyIntegration(t *testing.T) {

rr := httptest.NewRecorder()
rp.ServeHTTP(rr, tc.input)
rsp := rr.Result()

if rr.Result().StatusCode != 200 {
t.Errorf("Expected status 200 from proxy-response got %v", rr.Result().StatusCode)
if rsp.StatusCode != 200 {
t.Errorf("Expected status 200 from proxy-response got %v", rsp.StatusCode)
}

resultBody, err := ioutil.ReadAll(rr.Result().Body)
resultBody, err := ioutil.ReadAll(rsp.Body)
if err != nil {
t.Fatal("Error reading result body")
}
if err = rr.Result().Body.Close(); err != nil {
if err = rsp.Body.Close(); err != nil {
t.Fatal("Error closing result body")
}

Expand Down
8 changes: 6 additions & 2 deletions proxy/pkg/server/debug/server.go
Expand Up @@ -33,7 +33,9 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {

// TODO(tboerger): check if services are up and running

io.WriteString(w, http.StatusText(http.StatusOK))
if _, err := io.WriteString(w, http.StatusText(http.StatusOK)); err != nil {
panic(err)
}
}
}

Expand All @@ -45,6 +47,8 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {

// TODO(tboerger): check if services are up and running

io.WriteString(w, http.StatusText(http.StatusOK))
if _, err := io.WriteString(w, http.StatusText(http.StatusOK)); err != nil {
panic(err)
}
}
}
4 changes: 3 additions & 1 deletion proxy/pkg/server/http/server.go
Expand Up @@ -59,7 +59,9 @@ func Server(opts ...Option) (svc.Service, error) {
svc.Flags(options.Flags...),
)

micro.RegisterHandler(service.Server(), chain)
if err := micro.RegisterHandler(service.Server(), chain); err != nil {
return svc.Service{}, err
}

service.Init()
return service, nil
Expand Down

0 comments on commit a2e1e9f

Please sign in to comment.