Skip to content

Commit

Permalink
chore: update golangci-lint to v1.49.0 (#977)
Browse files Browse the repository at this point in the history
* chore: update golangci-lint to v1.49.0

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>

* chore: make readHeaderTimeout constant

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Sep 23, 2022
1 parent d6a6fa5 commit de2a52a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 310 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Expand Up @@ -6,7 +6,6 @@ run:
linters:
disable-all: true
enable:
- deadcode
- errorlint
- goconst
- gocyclo
Expand All @@ -21,8 +20,6 @@ linters:
- prealloc
- revive
- staticcheck
- structcheck
- unconvert
- unused
- varcheck
- whitespace
11 changes: 9 additions & 2 deletions cmd/main.go
Expand Up @@ -29,6 +29,10 @@ import (
k8spb "sigs.k8s.io/secrets-store-csi-driver/provider/v1alpha1"
)

const (
readHeaderTimeout = 5 * time.Second
)

var (
versionInfo = flag.Bool("version", false, "prints the version information")
endpoint = flag.String("endpoint", "unix:///tmp/azure.sock", "CSI gRPC endpoint")
Expand Down Expand Up @@ -71,8 +75,11 @@ func main() {
if *enableProfile {
klog.InfoS("Starting profiling", "port", *profilePort)
go func() {
addr := fmt.Sprintf("%s:%d", "localhost", *profilePort)
klog.ErrorS(http.ListenAndServe(addr, nil), "unable to start profiling server")
server := &http.Server{
Addr: fmt.Sprintf("%s:%d", "localhost", *profilePort),
ReadHeaderTimeout: readHeaderTimeout,
}
klog.ErrorS(server.ListenAndServe(), "unable to start profiling server")
}()
}
// initialize metrics exporter before creating measurements
Expand Down
11 changes: 10 additions & 1 deletion pkg/metrics/prometheus_exporter.go
Expand Up @@ -3,11 +3,16 @@ package metrics
import (
"fmt"
"net/http"
"time"

"go.opentelemetry.io/otel/exporters/metric/prometheus"
"k8s.io/klog/v2"
)

const (
readHeaderTimeout = 5 * time.Second
)

func initPrometheusExporter(port int) error {
pusher, err := prometheus.InstallNewPipeline(prometheus.Config{
DefaultHistogramBoundaries: []float64{
Expand All @@ -18,7 +23,11 @@ func initPrometheusExporter(port int) error {
}
http.HandleFunc("/metrics", pusher.ServeHTTP)
go func() {
klog.ErrorS(http.ListenAndServe(fmt.Sprintf(":%v", port), nil), "listen and server error")
server := &http.Server{
Addr: fmt.Sprintf(":%v", port),
ReadHeaderTimeout: readHeaderTimeout,
}
klog.ErrorS(server.ListenAndServe(), "listen and server error")
}()

return err
Expand Down
11 changes: 10 additions & 1 deletion pkg/server/healthz.go
Expand Up @@ -16,6 +16,10 @@ import (
"k8s.io/klog/v2"
)

const (
readHeaderTimeout = 5 * time.Second
)

type HealthZ struct {
HealthCheckURL *url.URL
UnixSocketPath string
Expand All @@ -26,7 +30,12 @@ type HealthZ struct {
func (h *HealthZ) Serve() {
serveMux := http.NewServeMux()
serveMux.HandleFunc(h.HealthCheckURL.EscapedPath(), h.ServeHTTP)
if err := http.ListenAndServe(h.HealthCheckURL.Host, serveMux); err != nil && errors.Is(err, http.ErrServerClosed) {
server := &http.Server{
Addr: h.HealthCheckURL.Host,
ReadHeaderTimeout: readHeaderTimeout,
Handler: serveMux,
}
if err := server.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
klog.ErrorS(err, "failed to start health check server")
os.Exit(1)
}
Expand Down
36 changes: 20 additions & 16 deletions tools/go.mod
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/client9/misspell v0.3.4
github.com/golang/mock v1.6.0
github.com/golangci/golangci-lint v1.48.0
github.com/golangci/golangci-lint v1.49.0
)

require (
Expand All @@ -14,7 +14,7 @@ require (
github.com/Antonboom/nilnil v0.1.1 // indirect
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.2 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/OpenPeeDeeP/depguard v1.1.0 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
Expand All @@ -30,8 +30,9 @@ require (
github.com/butuzov/ireturn v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/charithe/durationcheck v0.0.9 // indirect
github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect
github.com/daixiang0/gci v0.6.2 // indirect
github.com/chavacava/garif v0.0.0-20220630083739-93517212f375 // indirect
github.com/curioswitch/go-reassign v0.1.2 // indirect
github.com/daixiang0/gci v0.6.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect
github.com/esimonov/ifshort v1.0.4 // indirect
Expand All @@ -41,10 +42,10 @@ require (
github.com/firefart/nonamedreturns v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/go-critic/go-critic v0.6.3 // indirect
github.com/go-critic/go-critic v0.6.4 // indirect
github.com/go-toolsmith/astcast v1.0.0 // indirect
github.com/go-toolsmith/astcopy v1.0.0 // indirect
github.com/go-toolsmith/astequal v1.0.1 // indirect
github.com/go-toolsmith/astcopy v1.0.1 // indirect
github.com/go-toolsmith/astequal v1.0.2 // indirect
github.com/go-toolsmith/astfmt v1.0.0 // indirect
github.com/go-toolsmith/astp v1.0.0 // indirect
github.com/go-toolsmith/strparse v1.0.0 // indirect
Expand Down Expand Up @@ -90,12 +91,12 @@ require (
github.com/magiconair/properties v1.8.6 // indirect
github.com/maratori/testpackage v1.1.0 // indirect
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
github.com/mgechev/revive v1.2.1 // indirect
github.com/mgechev/revive v1.2.3 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moricho/tparallel v0.2.1 // indirect
Expand All @@ -109,20 +110,21 @@ require (
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.0.2 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
github.com/quasilyte/go-ruleguard v0.3.17 // indirect
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/ryancurrah/gomodguard v1.2.4 // indirect
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect
github.com/sashamelentyev/usestdlibvars v1.8.0 // indirect
github.com/securego/gosec/v2 v2.12.0 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.13.0 // indirect
github.com/securego/gosec/v2 v2.13.1 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sivchari/containedctx v1.0.2 // indirect
Expand All @@ -141,10 +143,11 @@ require (
github.com/stretchr/objx v0.4.0 // indirect
github.com/stretchr/testify v1.8.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/sylvia7788/contextcheck v1.0.4 // indirect
github.com/sylvia7788/contextcheck v1.0.6 // indirect
github.com/tdakkota/asciicheck v0.1.1 // indirect
github.com/tetafro/godot v1.4.11 // indirect
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 // indirect
github.com/timonwong/logrlint v0.1.0 // indirect
github.com/tomarrell/wrapcheck/v2 v2.6.2 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.0 // indirect
github.com/ultraware/funlen v0.0.3 // indirect
Expand All @@ -156,10 +159,11 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/protobuf v1.28.0 // indirect
Expand Down

0 comments on commit de2a52a

Please sign in to comment.