Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to go 1.20 #526

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run:
timeout: 2m
issues-exit-code: 1
tests: true
go: "1.17"
go: "1.20"
linters-settings:
goheader:
template-path: ".ci/license/template.txt"
Expand Down Expand Up @@ -42,13 +42,11 @@ linters-settings:
min-len: 2
min-occurrences: 2
depguard:
list-type: blacklist
include-go-root: false
packages:
- errors
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- errors: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
rules:
main:
deny:
- pkg: "errors"
desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
misspell:
locale: US
unparam:
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module github.com/networkservicemesh/sdk-sriov

go 1.18
go 1.20

require (
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.2.0
Expand All @@ -12,7 +13,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
go.uber.org/goleak v1.1.12
golang.org/x/sys v0.5.0
golang.org/x/sys v0.9.0
google.golang.org/grpc v1.49.0
)

Expand All @@ -23,7 +24,6 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/edwarnicke/exechelper v1.0.2 // indirect
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29 // indirect
github.com/edwarnicke/grpcfd v1.1.2 // indirect
github.com/edwarnicke/serialize v1.0.7 // indirect
github.com/go-logr/logr v1.2.3 // indirect
Expand Down Expand Up @@ -57,9 +57,9 @@ require (
go.opentelemetry.io/otel/sdk/metric v0.31.0 // indirect
go.opentelemetry.io/otel/trace v1.9.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/text v0.10.0 // indirect
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -315,7 +315,7 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -343,8 +343,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -391,17 +391,17 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -447,7 +447,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
25 changes: 0 additions & 25 deletions pkg/networkservice/common/resetmechanism/gen.go

This file was deleted.

77 changes: 0 additions & 77 deletions pkg/networkservice/common/resetmechanism/mechanism_map.gen.go

This file was deleted.

6 changes: 4 additions & 2 deletions pkg/networkservice/common/resetmechanism/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
// Copyright (c) 2023 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -20,6 +20,7 @@ package resetmechanism
import (
"context"

"github.com/edwarnicke/genericsync"
"github.com/golang/protobuf/ptypes/empty"

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
Expand All @@ -29,13 +30,14 @@ import (

type resetMechanismServer struct {
wrappedServer networkservice.NetworkServiceServer
mechanisms mechanismMap
mechanisms *genericsync.Map[string, *networkservice.Mechanism]
}

// NewServer returns a new reset mechanism server chain element
func NewServer(wrappedServer networkservice.NetworkServiceServer) networkservice.NetworkServiceServer {
return &resetMechanismServer{
wrappedServer: wrappedServer,
mechanisms: &genericsync.Map[string, *networkservice.Mechanism]{},
}
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/networkservice/common/token/multitoken/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2022 Nordix Foundation.
// Copyright (c) 2021-2023 Nordix Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -58,9 +58,8 @@ func (c *tokenElement) assign(tokenName string, conn *networkservice.Connection)
c.connectionsByTokens[tokenID] = conn.GetId()
c.tokensByConnections[conn.GetId()] = tokenID
break
} else {
tokenID = ""
}
tokenID = ""
}
return
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/sriov/pcifunction/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
package pcifunction

import (
"io/ioutil"
"os"

"path"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (f *Function) GetPCIAddress() string {

// GetNetInterfaceName returns f net interface name
func (f *Function) GetNetInterfaceName() (string, error) {
fInfos, err := ioutil.ReadDir(f.withDevicePath(netInterfacesPath))
fInfos, err := os.ReadDir(f.withDevicePath(netInterfacesPath))
if err != nil {
return "", errors.Wrapf(err, "failed to read net directory for the device: %v", f.address)
}
Expand Down Expand Up @@ -104,15 +105,15 @@ func (f *Function) BindDriver(driver string) error {
return nil
case boundDriver != "":
unbindPath := f.withDevicePath(boundDriverPath, unbindDriverPath)
if err := ioutil.WriteFile(unbindPath, []byte(f.address), 0); err != nil {
if err := os.WriteFile(unbindPath, []byte(f.address), 0); err != nil {
return errors.Wrapf(err, "failed to unbind driver from the device: %v", f.address)
}
}

// For some reasons write to the driver/bind file fails but binds the driver to the PCI function
// so we ignore error and simply compare the bound driver with the given one
bindPath := filepath.Join(f.pciDriversPath, driver, bindDriverPath)
err := ioutil.WriteFile(bindPath, []byte(f.address), 0)
err := os.WriteFile(bindPath, []byte(f.address), 0)
if boundDriver, _ := f.GetBoundDriver(); boundDriver != driver {
return errors.Wrapf(err, "failed to bind the driver to the device: %v %v", f.address, driver)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/sriov/pcifunction/physical_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package pcifunction

import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -104,12 +103,12 @@ func (pf *PhysicalFunction) createVirtualFunctions() error {
return nil
}

vfsCount, err := ioutil.ReadFile(pf.withDevicePath(totalVFFile))
vfsCount, err := os.ReadFile(pf.withDevicePath(totalVFFile))
if err != nil {
return errors.Wrapf(err, "failed to get available VFs number for the PCI device: %v", pf.address)
}

err = ioutil.WriteFile(pf.withDevicePath(configuredVFFile), vfsCount, 0)
err = os.WriteFile(pf.withDevicePath(configuredVFFile), vfsCount, 0)
if err != nil {
return errors.Wrapf(err, "failed to create VFs for the PCI device: %v", pf.address)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/sriov/pcifunction/tools.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
// Copyright (c) 2023 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -17,7 +17,6 @@
package pcifunction

import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -32,7 +31,7 @@ func isFileExists(path string) bool {
}

func readUintFromFile(path string) (uint, error) {
data, err := ioutil.ReadFile(filepath.Clean(path))
data, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return 0, errors.Wrapf(err, "unable to locate file: %v", path)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/tools/cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package cgroup

import (
"bufio"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (c *Cgroup) Allow(major, minor uint32) error {
dev := newDevice(major, minor, 'r', 'w', 'm')

filePath := filepath.Join(c.Path, deviceAllowFileName)
if err := ioutil.WriteFile(filePath, []byte(dev.String()), 0); err != nil {
if err := os.WriteFile(filePath, []byte(dev.String()), 0); err != nil {
return errors.Wrapf(err, "failed to write to a %s", filePath)
}

Expand All @@ -75,7 +74,7 @@ func (c *Cgroup) Deny(major, minor uint32) error {
dev := newDevice(major, minor, 'r', 'w')

filePath := filepath.Join(c.Path, deviceAllowFileName)
if err := ioutil.WriteFile(filePath, []byte(dev.String()), 0); err != nil {
if err := os.WriteFile(filePath, []byte(dev.String()), 0); err != nil {
return errors.Wrapf(err, "failed to write to a %s", filePath)
}

Expand Down
Loading