fix(lint): clean linter issues
All checks were successful
agola/nurse/Test and lint The run finished successfully

This commit is contained in:
Peter Kurfer 2022-09-22 14:04:53 +02:00
parent c52912c5aa
commit df6f6d55cb
No known key found for this signature in database
9 changed files with 14 additions and 9 deletions

View file

@ -52,7 +52,9 @@ func Identity[T any](in T) (T, error) {
}
func parseUint(val string) (uint, error) {
parsed, err := strconv.ParseUint(val, 10, 32)
const baseDecimal = 10
const int32BitSize = 32
parsed, err := strconv.ParseUint(val, baseDecimal, int32BitSize)
if err != nil {
return 0, err
}

View file

@ -24,6 +24,7 @@ const (
urlSchemeRegex = `^(?P<scheme>\w+)://((?P<username>[\w-.]+)(:(?P<password>.*))?@)?(\{(?P<hosts>(.+:\d{1,5})(,(.+:\d{1,5}))*)}|(?P<host>.+:\d{1,5}))(?P<path>/.*$)?`
)
//nolint:goconst
func (t ServerType) Scheme() string {
switch t {
case ServerTypeRedis:

View file

@ -5,6 +5,7 @@ import (
"log"
"net/http"
"os"
"time"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
@ -56,7 +57,13 @@ func main() {
logger.Fatal("Failed to prepare server mux", zap.Error(err))
}
if err := http.ListenAndServe(":8080", mux); err != nil {
srv := http.Server{
Addr: ":8080",
Handler: mux,
ReadHeaderTimeout: 100 * time.Millisecond,
}
if err := srv.ListenAndServe(); err != nil {
if errors.Is(err, http.ErrServerClosed) {
return
}

View file

@ -22,7 +22,6 @@ func Module() *check.Module {
return &GenericCheck{Method: http.MethodDelete}
})),
)
if err != nil {
panic(err)
}

View file

@ -37,7 +37,6 @@ func (g *GenericCheck) SetClient(client *http.Client) {
}
func (g *GenericCheck) Execute(ctx check.Context) error {
//TODO adopt
var body io.Reader
if len(g.Body) > 0 {
body = bytes.NewReader(g.Body)

View file

@ -14,7 +14,6 @@ func Module() *check.Module {
return new(GetCheck)
})),
)
if err != nil {
panic(err)
}

View file

@ -9,7 +9,6 @@ func Module() *check.Module {
return new(SelectCheck)
})),
)
if err != nil {
panic(err)
}

View file

@ -63,7 +63,7 @@ func TestChecks_Execute(t *testing.T) {
srvName, srv = PrepareMariaDBContainer(t)
case config.ServerTypePostgres:
srvName, srv = PreparePostgresContainer(t)
case config.ServerTypeRedis:
case config.ServerTypeRedis, config.ServerTypeUnspecified:
fallthrough
default:
t.Fatalf("unexpected server type: %s", st.Scheme())

View file

@ -36,10 +36,9 @@ func DBForServer(srv *config.Server) (*sql.DB, error) {
}
return sql.Open(srv.Type.Driver(), dsns[0])
case config.ServerTypeRedis:
case config.ServerTypeRedis, config.ServerTypeUnspecified:
fallthrough
default:
return nil, fmt.Errorf("unmatched server type for SQL DB: %s", srv.Type.Scheme())
}
}