From 920194716c679bea5668320680ce6d3bd4792612 Mon Sep 17 00:00:00 2001 From: Denis Tingaikin Date: Thu, 5 May 2022 21:01:43 +0300 Subject: [PATCH] update to go 1.18 Signed-off-by: Denis Tingaikin --- .github/workflows/ci.yaml | 14 +++--- .github/workflows/release.yaml | 2 +- .../update-dependent-repositories-gomod.yaml | 2 +- .golangci.yml | 5 ++- go.mod | 45 ++++++++++++++++++- pkg/networkservice/chains/forwarder/server.go | 1 + .../common/mechanisms/vfio/client.go | 9 ++-- .../common/mechanisms/vfio/client_test.go | 7 +-- .../common/mechanisms/vfio/const.go | 5 ++- .../common/mechanisms/vfio/option.go | 5 ++- .../common/mechanisms/vfio/server.go | 5 ++- .../common/mechanisms/vfio/server_test.go | 9 ++-- .../common/resourcepool/client.go | 5 ++- .../common/resourcepool/common.go | 5 ++- .../common/resourcepool/server.go | 3 +- .../common/resourcepool/server_test.go | 5 ++- pkg/networkservice/common/token/client.go | 5 ++- .../common/token/multitoken/client.go | 5 ++- .../common/token/multitoken/client_test.go | 5 ++- .../common/token/multitoken/common.go | 3 +- .../common/token/multitoken/server.go | 5 ++- pkg/networkservice/common/token/server.go | 5 ++- .../common/token/server_test.go | 3 +- .../common/token/sharedtoken/server.go | 3 +- pkg/sriov/pcifunction/function.go | 4 +- pkg/sriov/pcifunction/physical_function.go | 8 ++-- pkg/sriov/resource/pool.go | 18 ++++---- pkg/tools/cgroup/cgroup.go | 5 ++- pkg/tools/cgroup/cgroup_test.go | 7 +-- pkg/tools/cgroup/device.go | 5 ++- pkg/tools/cgroup/dir_path.go | 5 ++- pkg/tools/cgroup/fake_cgroup.go | 7 +-- pkg/tools/cgroup/file_api.go | 7 +-- 33 files changed, 147 insertions(+), 80 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6a02054..57cbf35 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - name: Build run: go build -race ./... - name: Test @@ -51,11 +51,11 @@ jobs: - name: Setup Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.35.0 + version: v1.45.2 excludeFmtErrorf: name: exclude fmt.Errorf @@ -92,7 +92,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - run: go mod tidy - name: Check for changes in go.mod or go.sum run: | @@ -109,11 +109,11 @@ jobs: version: '3.8.0' - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - name: Install proto-gen-go - run: go get -u github.com/golang/protobuf/protoc-gen-go@v1.3.3 + run: go install github.com/golang/protobuf/protoc-gen-go@v1.4.2 - name: Install proto-gen-go - run: go get github.com/searKing/golang/tools/cmd/go-syncmap + run: go install github.com/searKing/golang/tools/cmd/go-syncmap@v1.1.68 - name: Generate files run: go generate ./... - name: Check for changes in generated code diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 37a371f..61569cd 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -72,7 +72,7 @@ jobs: token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - name: Update ${{ github.repository }} locally working-directory: networkservicemesh/${{ matrix.repository }} run: | diff --git a/.github/workflows/update-dependent-repositories-gomod.yaml b/.github/workflows/update-dependent-repositories-gomod.yaml index 16e4b44..cb6f73f 100644 --- a/.github/workflows/update-dependent-repositories-gomod.yaml +++ b/.github/workflows/update-dependent-repositories-gomod.yaml @@ -64,7 +64,7 @@ jobs: token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18.1 - name: Update ${{ github.repository }} locally working-directory: networkservicemesh/${{ matrix.repository }} run: | diff --git a/.golangci.yml b/.golangci.yml index f5a9103..8d8e7b2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,7 @@ run: timeout: 2m issues-exit-code: 1 tests: true + go: "1.17" linters-settings: goheader: template-path: ".ci/license/template.txt" @@ -24,7 +25,7 @@ linters-settings: - (github.com/sirupsen/logrus.FieldLogger).Warnf - (github.com/sirupsen/logrus.FieldLogger).Errorf - (github.com/sirupsen/logrus.FieldLogger).Fatalf - golint: + revive: min-confidence: 0.8 goimports: local-prefixes: github.com/networkservicemesh/sdk-sriov @@ -143,7 +144,7 @@ linters: - gocyclo - gofmt - goimports - - golint + - revive - gosec - gosimple - govet diff --git a/go.mod b/go.mod index 28f1980..ee00b9c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/networkservicemesh/sdk-sriov -go 1.16 +go 1.18 require ( github.com/ghodss/yaml v1.0.0 @@ -12,7 +12,48 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 go.uber.org/goleak v1.1.12 - golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 google.golang.org/grpc v1.42.0 ) + +require ( + github.com/OneOfOne/xxhash v1.2.3 // indirect + github.com/antonfisher/nested-logrus-formatter v1.3.1 // indirect + github.com/cenkalti/backoff/v4 v4.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/edwarnicke/grpcfd v1.1.2 // indirect + github.com/edwarnicke/serialize v1.0.7 // indirect + github.com/go-logr/logr v1.2.1 // indirect + github.com/go-logr/stdr v1.2.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/open-policy-agent/opa v0.16.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect + github.com/stretchr/objx v0.1.1 // indirect + github.com/vishvananda/netlink v1.1.1-0.20220118170537-d6b03fdeb845 // indirect + github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect + github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b // indirect + go.opentelemetry.io/otel v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.26.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.26.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 // indirect + go.opentelemetry.io/otel/internal/metric v0.26.0 // indirect + go.opentelemetry.io/otel/metric v0.26.0 // indirect + go.opentelemetry.io/otel/sdk v1.3.0 // indirect + go.opentelemetry.io/otel/sdk/export/metric v0.26.0 // indirect + go.opentelemetry.io/otel/sdk/metric v0.26.0 // indirect + go.opentelemetry.io/otel/trace v1.3.0 // indirect + go.opentelemetry.io/proto/otlp v0.11.0 // indirect + golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/pkg/networkservice/chains/forwarder/server.go b/pkg/networkservice/chains/forwarder/server.go index 752939f..1be8e39 100644 --- a/pkg/networkservice/chains/forwarder/server.go +++ b/pkg/networkservice/chains/forwarder/server.go @@ -18,6 +18,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux // Package xconnectns provides an Endpoint implementing the SR-IOV Forwarder networks service diff --git a/pkg/networkservice/common/mechanisms/vfio/client.go b/pkg/networkservice/common/mechanisms/vfio/client.go index eb43252..a435a9e 100644 --- a/pkg/networkservice/common/mechanisms/vfio/client.go +++ b/pkg/networkservice/common/mechanisms/vfio/client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package vfio @@ -42,8 +43,8 @@ type vfioClient struct { } const ( - mkdirPerm = 0750 - mknodPerm = 0666 + mkdirPerm = 0o750 + mknodPerm = 0o666 ) // NewClient returns a new VFIO client chain element diff --git a/pkg/networkservice/common/mechanisms/vfio/client_test.go b/pkg/networkservice/common/mechanisms/vfio/client_test.go index f46deef..a8d3add 100644 --- a/pkg/networkservice/common/mechanisms/vfio/client_test.go +++ b/pkg/networkservice/common/mechanisms/vfio/client_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package vfio_test @@ -77,7 +78,7 @@ func TestVFIOClient_Request(t *testing.T) { defer cancel() tmpDir := filepath.Join(os.TempDir(), t.Name()) - err := os.MkdirAll(tmpDir, 0750) + err := os.MkdirAll(tmpDir, 0o750) require.NoError(t, err) defer func() { _ = os.RemoveAll(tmpDir) }() diff --git a/pkg/networkservice/common/mechanisms/vfio/const.go b/pkg/networkservice/common/mechanisms/vfio/const.go index b26158c..d544dab 100644 --- a/pkg/networkservice/common/mechanisms/vfio/const.go +++ b/pkg/networkservice/common/mechanisms/vfio/const.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package vfio diff --git a/pkg/networkservice/common/mechanisms/vfio/option.go b/pkg/networkservice/common/mechanisms/vfio/option.go index bede948..326e5ed 100644 --- a/pkg/networkservice/common/mechanisms/vfio/option.go +++ b/pkg/networkservice/common/mechanisms/vfio/option.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package vfio diff --git a/pkg/networkservice/common/mechanisms/vfio/server.go b/pkg/networkservice/common/mechanisms/vfio/server.go index dd12c00..e9bd954 100644 --- a/pkg/networkservice/common/mechanisms/vfio/server.go +++ b/pkg/networkservice/common/mechanisms/vfio/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows // Package vfio provides server, vfioClient chain elements for the VFIO mechanism connection package vfio diff --git a/pkg/networkservice/common/mechanisms/vfio/server_test.go b/pkg/networkservice/common/mechanisms/vfio/server_test.go index 572cc8c..fd43e7a 100644 --- a/pkg/networkservice/common/mechanisms/vfio/server_test.go +++ b/pkg/networkservice/common/mechanisms/vfio/server_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package vfio_test @@ -101,9 +102,9 @@ func TestVFIOServer_Request(t *testing.T) { notAllowed, allowed, wider := testCgroups(ctx, t, tmpDir) - err := unix.Mknod(filepath.Join(tmpDir, vfioDevice), unix.S_IFCHR|0666, int(unix.Mkdev(1, 2))) + err := unix.Mknod(filepath.Join(tmpDir, vfioDevice), unix.S_IFCHR|0o666, int(unix.Mkdev(1, 2))) require.NoError(t, err) - err = unix.Mknod(filepath.Join(tmpDir, iommuGroupString), unix.S_IFCHR|0666, int(unix.Mkdev(3, 4))) + err = unix.Mknod(filepath.Join(tmpDir, iommuGroupString), unix.S_IFCHR|0o666, int(unix.Mkdev(3, 4))) require.NoError(t, err) conn, err := server.Request(ctx, &networkservice.NetworkServiceRequest{ diff --git a/pkg/networkservice/common/resourcepool/client.go b/pkg/networkservice/common/resourcepool/client.go index ebb10a7..63977cb 100644 --- a/pkg/networkservice/common/resourcepool/client.go +++ b/pkg/networkservice/common/resourcepool/client.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package resourcepool diff --git a/pkg/networkservice/common/resourcepool/common.go b/pkg/networkservice/common/resourcepool/common.go index 1d4835a..4e979bf 100644 --- a/pkg/networkservice/common/resourcepool/common.go +++ b/pkg/networkservice/common/resourcepool/common.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package resourcepool diff --git a/pkg/networkservice/common/resourcepool/server.go b/pkg/networkservice/common/resourcepool/server.go index 60b2b60..3c7eca3 100644 --- a/pkg/networkservice/common/resourcepool/server.go +++ b/pkg/networkservice/common/resourcepool/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux // Package resourcepool provides chain elements for to select and free VF diff --git a/pkg/networkservice/common/resourcepool/server_test.go b/pkg/networkservice/common/resourcepool/server_test.go index d51e713..55d7871 100644 --- a/pkg/networkservice/common/resourcepool/server_test.go +++ b/pkg/networkservice/common/resourcepool/server_test.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package resourcepool_test diff --git a/pkg/networkservice/common/token/client.go b/pkg/networkservice/common/token/client.go index 389d94f..3edd8bb 100644 --- a/pkg/networkservice/common/token/client.go +++ b/pkg/networkservice/common/token/client.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux // Package token provides chain elements for inserting SRIOV tokens into request and response diff --git a/pkg/networkservice/common/token/multitoken/client.go b/pkg/networkservice/common/token/multitoken/client.go index 95ead8e..b7ea3eb 100644 --- a/pkg/networkservice/common/token/multitoken/client.go +++ b/pkg/networkservice/common/token/multitoken/client.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux // Package multitoken provides chain elements for inserting SRIOV tokens into request and response diff --git a/pkg/networkservice/common/token/multitoken/client_test.go b/pkg/networkservice/common/token/multitoken/client_test.go index c3a66ac..0a31d1f 100644 --- a/pkg/networkservice/common/token/multitoken/client_test.go +++ b/pkg/networkservice/common/token/multitoken/client_test.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package multitoken_test diff --git a/pkg/networkservice/common/token/multitoken/common.go b/pkg/networkservice/common/token/multitoken/common.go index 3cf1f7f..c1e6147 100644 --- a/pkg/networkservice/common/token/multitoken/common.go +++ b/pkg/networkservice/common/token/multitoken/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package multitoken diff --git a/pkg/networkservice/common/token/multitoken/server.go b/pkg/networkservice/common/token/multitoken/server.go index 1217256..ed79bfb 100644 --- a/pkg/networkservice/common/token/multitoken/server.go +++ b/pkg/networkservice/common/token/multitoken/server.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package multitoken diff --git a/pkg/networkservice/common/token/server.go b/pkg/networkservice/common/token/server.go index fe879cc..6ffd968 100644 --- a/pkg/networkservice/common/token/server.go +++ b/pkg/networkservice/common/token/server.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,6 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package token diff --git a/pkg/networkservice/common/token/server_test.go b/pkg/networkservice/common/token/server_test.go index 22fe9e0..ede1aa8 100644 --- a/pkg/networkservice/common/token/server_test.go +++ b/pkg/networkservice/common/token/server_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package token_test diff --git a/pkg/networkservice/common/token/sharedtoken/server.go b/pkg/networkservice/common/token/sharedtoken/server.go index bd55e9f..f5375b8 100644 --- a/pkg/networkservice/common/token/sharedtoken/server.go +++ b/pkg/networkservice/common/token/sharedtoken/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,6 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux // Package sharedtoken provides server chain element for inserting shared SRIOV token into request and response diff --git a/pkg/sriov/pcifunction/function.go b/pkg/sriov/pcifunction/function.go index 0ae5bc9..609628d 100644 --- a/pkg/sriov/pcifunction/function.go +++ b/pkg/sriov/pcifunction/function.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -101,7 +101,7 @@ func (f *Function) BindDriver(driver string) error { case boundDriver == driver: return nil case boundDriver != "": - unbindPath := filepath.Join(f.withDevicePath(boundDriverPath, unbindDriverPath)) + unbindPath := f.withDevicePath(boundDriverPath, unbindDriverPath) if err := ioutil.WriteFile(unbindPath, []byte(f.address), 0); err != nil { return errors.Wrapf(err, "failed to unbind driver from the device: %v", f.address) } diff --git a/pkg/sriov/pcifunction/physical_function.go b/pkg/sriov/pcifunction/physical_function.go index 0cf93ed..f2140e0 100644 --- a/pkg/sriov/pcifunction/physical_function.go +++ b/pkg/sriov/pcifunction/physical_function.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -122,9 +122,9 @@ func (pf *PhysicalFunction) loadVirtualFunctions() error { } sort.Slice(vfDirs, func(i, k int) bool { - iVFNum, _ := strconv.Atoi(strings.TrimPrefix(vfDirs[i], virtualFunctionPrefix)) - kVFNum, _ := strconv.Atoi(strings.TrimPrefix(vfDirs[k], virtualFunctionPrefix)) - return iVFNum < kVFNum + leftVFNum, _ := strconv.Atoi(strings.TrimPrefix(vfDirs[i], virtualFunctionPrefix)) + rightVFNum, _ := strconv.Atoi(strings.TrimPrefix(vfDirs[k], virtualFunctionPrefix)) + return leftVFNum < rightVFNum }) for _, vfDir := range vfDirs { diff --git a/pkg/sriov/resource/pool.go b/pkg/sriov/resource/pool.go index 4cac47f..8f2b21b 100644 --- a/pkg/sriov/resource/pool.go +++ b/pkg/sriov/resource/pool.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -118,18 +118,18 @@ func (p *Pool) Select(tokenID string, driverType sriov.DriverType) (string, erro } sort.Slice(vfs, func(i, k int) bool { - iIg := p.iommuGroups[vfs[i].iommuGroup] - kIg := p.iommuGroups[vfs[k].iommuGroup] - iPF := p.physicalFunctions[vfs[i].pfPCIAddr] - kPF := p.physicalFunctions[vfs[k].pfPCIAddr] + leftIG := p.iommuGroups[vfs[i].iommuGroup] + rightIG := p.iommuGroups[vfs[k].iommuGroup] + leftPF := p.physicalFunctions[vfs[i].pfPCIAddr] + rightPF := p.physicalFunctions[vfs[k].pfPCIAddr] switch { - case iIg == driverType && kIg == sriov.NoDriver: + case leftIG == driverType && rightIG == sriov.NoDriver: return true - case iIg == sriov.NoDriver && kIg == driverType: + case leftIG == sriov.NoDriver && rightIG == driverType: return false - case iPF.freeVFsCount > kPF.freeVFsCount: + case leftPF.freeVFsCount > rightPF.freeVFsCount: return true - case iPF.freeVFsCount < kPF.freeVFsCount: + case leftPF.freeVFsCount < rightPF.freeVFsCount: return false default: // we need this additional comparison to make sort deterministic diff --git a/pkg/tools/cgroup/cgroup.go b/pkg/tools/cgroup/cgroup.go index afd4266..6428c4e 100644 --- a/pkg/tools/cgroup/cgroup.go +++ b/pkg/tools/cgroup/cgroup.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup diff --git a/pkg/tools/cgroup/cgroup_test.go b/pkg/tools/cgroup/cgroup_test.go index 7ea1acc..e8cd6ab 100644 --- a/pkg/tools/cgroup/cgroup_test.go +++ b/pkg/tools/cgroup/cgroup_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup_test @@ -30,7 +31,7 @@ import ( ) const ( - mkdirPerm = 0750 + mkdirPerm = 0o750 deviceListFileName = "devices.list" ) diff --git a/pkg/tools/cgroup/device.go b/pkg/tools/cgroup/device.go index b59df8d..57d526a 100644 --- a/pkg/tools/cgroup/device.go +++ b/pkg/tools/cgroup/device.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup diff --git a/pkg/tools/cgroup/dir_path.go b/pkg/tools/cgroup/dir_path.go index 710e930..df51a12 100644 --- a/pkg/tools/cgroup/dir_path.go +++ b/pkg/tools/cgroup/dir_path.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup diff --git a/pkg/tools/cgroup/fake_cgroup.go b/pkg/tools/cgroup/fake_cgroup.go index f500900..8debbc0 100644 --- a/pkg/tools/cgroup/fake_cgroup.go +++ b/pkg/tools/cgroup/fake_cgroup.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup @@ -30,7 +31,7 @@ import ( ) const ( - mkdirPerm = 0750 + mkdirPerm = 0o750 ) // NewFakeCgroup creates and returns a new cgroup for testing with some k8s default devices allowed. diff --git a/pkg/tools/cgroup/file_api.go b/pkg/tools/cgroup/file_api.go index cb5ce4f..24a81f1 100644 --- a/pkg/tools/cgroup/file_api.go +++ b/pkg/tools/cgroup/file_api.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -14,7 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build !windows +//go:build !windows +// +build !windows package cgroup @@ -28,7 +29,7 @@ import ( ) const ( - createPerm = 0666 + createPerm = 0o666 ) func inputFileAPI(ctx context.Context, filePath string, consumer func(string)) error {