From cc417c6ee8ec4363fd569a6309bdfa9d922dec38 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Wed, 24 Feb 2021 14:48:22 +0100 Subject: [PATCH] resolve linter issues --- idp/go.mod | 1 - idp/go.sum | 9 +++++---- idp/pkg/server/debug/server.go | 8 ++++++-- idp/pkg/server/http/server.go | 6 ++++-- idp/pkg/service/v0/instrument.go | 5 ----- idp/pkg/service/v0/logging.go | 5 ----- idp/pkg/service/v0/service.go | 13 +++---------- idp/pkg/service/v0/tracing.go | 5 ----- 8 files changed, 18 insertions(+), 34 deletions(-) diff --git a/idp/go.mod b/idp/go.mod index 2c3092320f..ae6f2a0e93 100644 --- a/idp/go.mod +++ b/idp/go.mod @@ -31,7 +31,6 @@ require ( golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b - golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect stash.kopano.io/kc/konnect v0.33.3 stash.kopano.io/kgol/rndm v1.1.0 ) diff --git a/idp/go.sum b/idp/go.sum index e721060e66..72c421ec5b 100644 --- a/idp/go.sum +++ b/idp/go.sum @@ -273,8 +273,8 @@ github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5/go.mod h1:UXha4T github.com/cs3org/reva v1.1.0/go.mod h1:fBzTrNuAKdQ62ybjpdu8nyhBin90/3/3s6DGQDCdBp4= github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c h1:fyo4TNiZdfQS27XHnAMb+S2wkdlmBf6ZLkU4uHEgWSA= github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c/go.mod h1:24c68Ys3h7srGohymDKSXakN4OrhzABJoKFoMeSIBvk= -github.com/cs3org/reva v1.6.0 h1:xIhO7UtXQZbjYNeekaeQtZRo+HjZWWukCotb1tO4qMA= -github.com/cs3org/reva v1.6.0/go.mod h1:3IWlJ4RcYYu0NEnlvP9QG66Inx7F0BtVLJWXit9Q5aw= +github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e h1:fylXfGSnDzo+X+sgxNyWoU1NjAmTJBrj2ucgNKBmb6s= +github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e/go.mod h1:DGqsIK/psLwnWz58z8t4Gmrhx9P5iccZZkzi8CBO1c0= github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -666,6 +666,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -1761,8 +1762,8 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9Mea golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b h1:lAZ0/chPUDWwjqosYR0X4M490zQhMsiJ4K3DbA7o+3g= +golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= diff --git a/idp/pkg/server/debug/server.go b/idp/pkg/server/debug/server.go index 13ab7b9f27..f05038d95a 100644 --- a/idp/pkg/server/debug/server.go +++ b/idp/pkg/server/debug/server.go @@ -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) + } } } @@ -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) + } } } diff --git a/idp/pkg/server/http/server.go b/idp/pkg/server/http/server.go index bafbed9997..2bed18c369 100644 --- a/idp/pkg/server/http/server.go +++ b/idp/pkg/server/http/server.go @@ -40,7 +40,7 @@ func Server(opts ...Option) (http.Service, error) { os.Exit(1) } - tlsConfig = &tls.Config{Certificates: []tls.Certificate{cer}} + tlsConfig = &tls.Config{MinVersion: tls.VersionTLS12, Certificates: []tls.Certificate{cer}} } service := http.NewService( @@ -79,7 +79,9 @@ func Server(opts ...Option) (http.Service, error) { handle = svc.NewLogging(handle, options.Logger) } - micro.RegisterHandler(service.Server(), handle) + if err := micro.RegisterHandler(service.Server(), handle); err != nil { + return http.Service{}, err + } service.Init() return service, nil diff --git a/idp/pkg/service/v0/instrument.go b/idp/pkg/service/v0/instrument.go index 9d5ad73225..1f5eac3e9e 100644 --- a/idp/pkg/service/v0/instrument.go +++ b/idp/pkg/service/v0/instrument.go @@ -23,8 +23,3 @@ type instrument struct { func (i instrument) ServeHTTP(w http.ResponseWriter, r *http.Request) { i.next.ServeHTTP(w, r) } - -// Dummy implements the Service interface. -func (i instrument) Dummy(w http.ResponseWriter, r *http.Request) { - i.next.Dummy(w, r) -} diff --git a/idp/pkg/service/v0/logging.go b/idp/pkg/service/v0/logging.go index dd34077cfc..d5098e2fe2 100644 --- a/idp/pkg/service/v0/logging.go +++ b/idp/pkg/service/v0/logging.go @@ -23,8 +23,3 @@ type logging struct { func (l logging) ServeHTTP(w http.ResponseWriter, r *http.Request) { l.next.ServeHTTP(w, r) } - -// Dummy implements the Service interface. -func (l logging) Dummy(w http.ResponseWriter, r *http.Request) { - l.next.Dummy(w, r) -} diff --git a/idp/pkg/service/v0/service.go b/idp/pkg/service/v0/service.go index c3a8be6780..a5e8390b15 100644 --- a/idp/pkg/service/v0/service.go +++ b/idp/pkg/service/v0/service.go @@ -25,7 +25,6 @@ import ( // Service defines the extension handlers. type Service interface { ServeHTTP(http.ResponseWriter, *http.Request) - Dummy(http.ResponseWriter, *http.Request) } // NewService returns a service implementation for Service. @@ -178,14 +177,6 @@ func (k IDP) ServeHTTP(w http.ResponseWriter, r *http.Request) { k.mux.ServeHTTP(w, r) } -// Dummy implements the Service interface. -func (k IDP) Dummy(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain") - w.WriteHeader(http.StatusOK) - - w.Write([]byte(http.StatusText(http.StatusOK))) -} - // Index renders the static html with the func (k IDP) Index() http.HandlerFunc { @@ -211,6 +202,8 @@ func (k IDP) Index() http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) - w.Write(indexHTML) + if _, err := w.Write(indexHTML); err != nil { + k.logger.Error().Err(err).Msg("could not write to response writer") + } }) } diff --git a/idp/pkg/service/v0/tracing.go b/idp/pkg/service/v0/tracing.go index 474959ed00..1857cf0d8d 100644 --- a/idp/pkg/service/v0/tracing.go +++ b/idp/pkg/service/v0/tracing.go @@ -21,8 +21,3 @@ type tracing struct { func (t tracing) ServeHTTP(w http.ResponseWriter, r *http.Request) { middleware.Trace(t.next).ServeHTTP(w, r) } - -// Dummy implements the Service interface. -func (t tracing) Dummy(w http.ResponseWriter, r *http.Request) { - t.next.Dummy(w, r) -}