Skip to content

Commit ef481f1

Browse files
committed
Upgrade golangci-lint to v1.48.0
Go 1.19 support was added in golangci-lint v1.48.0. Resolves new warnings from gofmt and gosec. Signed-off-by: Austin Vazquez <[email protected]>
1 parent 5238aea commit ef481f1

File tree

6 files changed

+40
-31
lines changed

6 files changed

+40
-31
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ tidy:
136136
./tools/tidy.sh
137137

138138
$(BINPATH)/golangci-lint:
139-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(BINPATH) v1.46.2
139+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(BINPATH) v1.48.0
140140
$(BINPATH)/golangci-lint --version
141141

142142
$(BINPATH)/git-validation:

internal/vm/oci.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func updateUserInSpec(ctx context.Context, s *specs.Spec, rootfsMount mount.Moun
8282

8383
// withUser sets the user to be used within the container.
8484
// It accepts a valid user string in OCI Image Spec v1.0.0:
85-
// user, uid, user:group, uid:gid, uid:group, user:gid
85+
//
86+
// user, uid, user:group, uid:gid, uid:group, user:gid
8687
func withUser(ctx context.Context, s *specs.Spec, rootfsMount mount.Mount, userstr string) error {
8788
parts := strings.Split(userstr, ":")
8889
switch len(parts) {

runtime/cpuset/cpuset_builder.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,32 @@ import (
2323
// cpuset.mems
2424
//
2525
// Example:
26-
// cset := cpuset.Builder{}.
27-
// AddCPU(0).
28-
// AddMemRange(0).
29-
// Build()
3026
//
31-
// fcClient, err := fcclient.New(containerdTTRPCAddress)
32-
// if err != nil {
33-
// return err
34-
// }
27+
// cset := cpuset.Builder{}.
28+
// AddCPU(0).
29+
// AddMemRange(0).
30+
// Build()
3531
//
36-
// defer fcClient.Close()
32+
// fcClient, err := fcclient.New(containerdTTRPCAddress)
33+
// if err != nil {
34+
// return err
35+
// }
3736
//
38-
// vmID := "cpuset-builder-example"
39-
// createVMRequest := &proto.CreateVMRequest{
40-
// VMID: vmID,
41-
// JailerConfig: proto.JailerConfig{
42-
// CPUs: cset.CPUs(),
43-
// Mems: cset.Mems(),
44-
// },
45-
// }
37+
// defer fcClient.Close()
4638
//
47-
// _, err = fcClient.CreateVM(ctx, createVMRequest)
48-
// if err != nil {
49-
// return fmt.Errorf("failed to create VM: %w", err)
50-
// }
39+
// vmID := "cpuset-builder-example"
40+
// createVMRequest := &proto.CreateVMRequest{
41+
// VMID: vmID,
42+
// JailerConfig: proto.JailerConfig{
43+
// CPUs: cset.CPUs(),
44+
// Mems: cset.Mems(),
45+
// },
46+
// }
47+
//
48+
// _, err = fcClient.CreateVM(ctx, createVMRequest)
49+
// if err != nil {
50+
// return fmt.Errorf("failed to create VM: %w", err)
51+
// }
5152
type Builder struct {
5253
cpus []int
5354
cpuRanges []_range

snapshotter/demux/metrics/discovery/service_discovery.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"fmt"
2020
"net/http"
2121
"strconv"
22+
"time"
2223

2324
"github.com/containerd/containerd/log"
2425
"github.com/firecracker-microvm/firecracker-containerd/snapshotter/demux/cache"
@@ -37,7 +38,8 @@ type ServiceDiscovery struct {
3738
func NewServiceDiscovery(host string, port int, c *cache.RemoteSnapshotterCache) *ServiceDiscovery {
3839
return &ServiceDiscovery{
3940
server: &http.Server{
40-
Addr: host + ":" + strconv.Itoa(port),
41+
Addr: host + ":" + strconv.Itoa(port),
42+
ReadHeaderTimeout: 2 * time.Second,
4143
},
4244
cache: c,
4345
}

snapshotter/demux/metrics/proxy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"net/http"
2222
"strconv"
2323
"sync"
24+
"time"
2425

2526
"github.com/containerd/containerd/log"
2627
)
@@ -143,8 +144,9 @@ func (mp *Proxy) Serve(ctx context.Context) error {
143144
mux.HandleFunc("/metrics", mp.metrics)
144145

145146
mp.server = &http.Server{
146-
Addr: mp.host + ":" + strconv.Itoa(mp.Port),
147-
Handler: mux,
147+
Addr: mp.host + ":" + strconv.Itoa(mp.Port),
148+
Handler: mux,
149+
ReadHeaderTimeout: 2 * time.Second,
148150
}
149151

150152
err := mp.server.ListenAndServe()

snapshotter/internal/http_address_resolver.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"os/signal"
2424
"strconv"
2525
"syscall"
26+
"time"
2627

2728
"github.com/containerd/containerd/namespaces"
2829
"github.com/sirupsen/logrus"
@@ -56,10 +57,11 @@ func init() {
5657
// curl -X GET "http://localhost:10001/address?namespace=ns-1"
5758
//
5859
// Response:
59-
// {
60-
// "network": "unix",
61-
// "address": "/var/lib/firecracker-containerd/shim-base/default#cbfad871-0862-4dd6-ae7a-52e9b1c16ede/firecracker.vsock"
62-
// }
60+
//
61+
// {
62+
// "network": "unix",
63+
// "address": "/var/lib/firecracker-containerd/shim-base/default#cbfad871-0862-4dd6-ae7a-52e9b1c16ede/firecracker.vsock"
64+
// }
6365
func main() {
6466
ctx, cancel := context.WithCancel(context.Background())
6567

@@ -77,7 +79,8 @@ func main() {
7779

7880
http.HandleFunc("/address", queryAddress)
7981
httpServer := &http.Server{
80-
Addr: fmt.Sprintf("127.0.0.1:%d", port),
82+
Addr: fmt.Sprintf("127.0.0.1:%d", port),
83+
ReadHeaderTimeout: 10 * time.Second,
8184
}
8285

8386
logger.Info(fmt.Sprintf("http resolver serving at port %d", port))

0 commit comments

Comments
 (0)