From 89cf168c921e478cfdb94160885a30ac09d26c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 9 Jul 2021 17:15:10 +0200 Subject: [PATCH 1/3] virtcontainers: Ignore a staticcheck error on cpuset.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First of all, cpuset.go just comes from kubernetes and we shouldn't be doing much with this file apart from updating it every now and then (but that's material for another PR). Right now, due to some change on the static checks we use as part of our CI, we started getting issues as: ``` INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/cpuset cpuset.go:60:2: SA4005: ineffective assignment to field Builder.done (staticcheck) b.done = true ``` For those, let's just ignore the lint and move on. Signed-off-by: Fabiano FidĂȘncio --- src/runtime/virtcontainers/pkg/cpuset/cpuset.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runtime/virtcontainers/pkg/cpuset/cpuset.go b/src/runtime/virtcontainers/pkg/cpuset/cpuset.go index ee944c9714..a83b13273c 100644 --- a/src/runtime/virtcontainers/pkg/cpuset/cpuset.go +++ b/src/runtime/virtcontainers/pkg/cpuset/cpuset.go @@ -57,6 +57,7 @@ func (b Builder) Add(elems ...int) { // Result returns the result CPUSet containing all elements that were // previously added to this builder. Subsequent calls to Add have no effect. func (b Builder) Result() CPUSet { + // nolint: staticcheck b.done = true return b.result } From 305fb0547d6be967df4145f0da7d0d2d411fe72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 9 Jul 2021 17:18:08 +0200 Subject: [PATCH 2/3] virtcontainers: Fix `gosimple` issue on client.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason our static check started to get opinionated about code that's been there for ages. One of the suggestions is to improve: ``` INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client client.go:431:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple) if strings.HasPrefix(sock, "mock:") { ``` And that's what this PR is about. Signed-off-by: Fabiano FidĂȘncio --- .../virtcontainers/pkg/agent/protocols/client/client.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go b/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go index 362dca0ad2..86a1943ceb 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go +++ b/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go @@ -428,9 +428,7 @@ func HybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) { // just for tests use. func MockHybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) { - if strings.HasPrefix(sock, "mock:") { - sock = strings.TrimPrefix(sock, "mock:") - } + sock = strings.TrimPrefix(sock, "mock:") dialFunc := func() (net.Conn, error) { return net.DialTimeout("unix", sock, timeout) From da3de3c2eb91ce7d00709f454d88c8f41657e365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 9 Jul 2021 17:21:16 +0200 Subject: [PATCH 3/3] shim-v2: Fix `gosimple` issue on utils_test.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason our static check started to get opinionated about code that's been there for ages. One of the suggestions is to improve: ``` INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/containerd-shim-v2 utils_test.go:76:36: S1039: unnecessary use of fmt.Sprintf (gosimple) testDir, err = ioutil.TempDir("", fmt.Sprintf("shimV2-")) ``` And that's what this PR is about. Fixes: #2204 Signed-off-by: Fabiano FidĂȘncio --- src/runtime/containerd-shim-v2/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/containerd-shim-v2/utils_test.go b/src/runtime/containerd-shim-v2/utils_test.go index 492a0b41cf..96faeaf719 100644 --- a/src/runtime/containerd-shim-v2/utils_test.go +++ b/src/runtime/containerd-shim-v2/utils_test.go @@ -73,7 +73,7 @@ func init() { var err error fmt.Printf("INFO: creating test directory\n") - testDir, err = ioutil.TempDir("", fmt.Sprintf("shimV2-")) + testDir, err = ioutil.TempDir("", "shimV2-") if err != nil { panic(fmt.Sprintf("ERROR: failed to create test directory: %v", err)) }