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

bump gopkg.in/yaml.v2 #248

Merged
merged 3 commits into from
Apr 18, 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
2 changes: 1 addition & 1 deletion .github/workflows/static-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.49
version: v1.52.2
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions cmd/sriov/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func cmdAdd(args *skel.CmdArgs) error {
return err
})
if err == nil {
_ = sm.ReleaseVF(netConf, args.IfName, args.ContainerID, netns)
_ = sm.ReleaseVF(netConf, args.IfName, netns)
}
// Reset the VF if failure occurs before the netconf is cached
_ = sm.ResetVFConfig(netConf)
Expand All @@ -102,7 +102,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}}

if !netConf.DPDKMode {
macAddr, err = sm.SetupVF(netConf, args.IfName, args.ContainerID, netns)
macAddr, err = sm.SetupVF(netConf, args.IfName, netns)

if err != nil {
return fmt.Errorf("failed to set up pod interface %q from the device %q: %v", args.IfName, netConf.Master, err)
Expand Down Expand Up @@ -246,7 +246,7 @@ func cmdDel(args *skel.CmdArgs) error {
}
defer netns.Close()

if err = sm.ReleaseVF(netConf, args.IfName, args.ContainerID, netns); err != nil {
if err = sm.ReleaseVF(netConf, args.IfName, netns); err != nil {
return err
}
}
Expand All @@ -260,7 +260,7 @@ func cmdDel(args *skel.CmdArgs) error {
return nil
}

func cmdCheck(args *skel.CmdArgs) error {
func cmdCheck(_ *skel.CmdArgs) error {
return nil
}

Expand Down
35 changes: 21 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@ go 1.19

require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.1.1
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.17.0
github.com/stretchr/testify v1.5.1
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
golang.org/x/net v0.7.0
github.com/containernetworking/plugins v1.2.0
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.5
github.com/stretchr/testify v1.6.1
github.com/vishvananda/netlink v1.2.1-beta.2
golang.org/x/net v0.8.0
)

require (
github.com/coreos/go-iptables v0.6.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1 // indirect
github.com/safchain/ethtool v0.2.0 // indirect
github.com/stretchr/objx v0.1.0 // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
github.com/vishvananda/netns v0.0.2 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace (
github.com/onsi/ginkgo/v2 => github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega => github.com/onsi/gomega v1.27.5
)
139 changes: 59 additions & 80 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/config/config_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/k8snetworkplumbingwg/sriov-cni/pkg/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/k8snetworkplumbingwg/sriov-cni/pkg/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"os"
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/sriov/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (p *pciUtilsImpl) EnableArpAndNdiscNotify(ifName string) error {

// Manager provides interface invoke sriov nic related operations
type Manager interface {
SetupVF(conf *sriovtypes.NetConf, podifName string, cid string, netns ns.NetNS) (string, error)
ReleaseVF(conf *sriovtypes.NetConf, podifName string, cid string, netns ns.NetNS) error
SetupVF(conf *sriovtypes.NetConf, podifName string, netns ns.NetNS) (string, error)
ReleaseVF(conf *sriovtypes.NetConf, podifName string, netns ns.NetNS) error
ResetVFConfig(conf *sriovtypes.NetConf) error
ApplyVFConfig(conf *sriovtypes.NetConf) error
FillOriginalVfInfo(conf *sriovtypes.NetConf) error
Expand All @@ -60,7 +60,7 @@ func NewSriovManager() Manager {
}

// SetupVF sets up a VF in Pod netns
func (s *sriovManager) SetupVF(conf *sriovtypes.NetConf, podifName string, cid string, netns ns.NetNS) (string, error) {
func (s *sriovManager) SetupVF(conf *sriovtypes.NetConf, podifName string, netns ns.NetNS) (string, error) {
linkName := conf.OrigVfState.HostIFName

linkObj, err := s.nLink.LinkByName(linkName)
Expand Down Expand Up @@ -141,7 +141,7 @@ func (s *sriovManager) SetupVF(conf *sriovtypes.NetConf, podifName string, cid s
}

// ReleaseVF reset a VF from Pod netns and return it to init netns
func (s *sriovManager) ReleaseVF(conf *sriovtypes.NetConf, podifName string, cid string, netns ns.NetNS) error {
func (s *sriovManager) ReleaseVF(conf *sriovtypes.NetConf, podifName string, netns ns.NetNS) error {
initns, err := ns.GetCurrentNS()
if err != nil {
return fmt.Errorf("failed to get init netns: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sriov/sriov_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sriov

import (
"github.com/k8snetworkplumbingwg/sriov-cni/pkg/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"testing"
Expand Down
16 changes: 5 additions & 11 deletions pkg/sriov/sriov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/k8snetworkplumbingwg/sriov-cni/pkg/sriov/mocks"
sriovtypes "github.com/k8snetworkplumbingwg/sriov-cni/pkg/types"
mocks_utils "github.com/k8snetworkplumbingwg/sriov-cni/pkg/utils/mocks"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/mock"
"github.com/vishvananda/netlink"
Expand Down Expand Up @@ -42,13 +42,11 @@ var _ = Describe("Sriov", func() {
Context("Checking SetupVF function", func() {
var (
podifName string
contID string
netconf *sriovtypes.NetConf
)

BeforeEach(func() {
podifName = "net1"
contID = "dummycid"
netconf = &sriovtypes.NetConf{
Master: "enp175s0f1",
DeviceID: "0000:af:06.0",
Expand Down Expand Up @@ -91,7 +89,7 @@ var _ = Describe("Sriov", func() {
mocked.On("LinkSetVfVlanQos", mock.Anything, mock.AnythingOfType("int"), mock.AnythingOfType("int"), mock.AnythingOfType("int")).Return(nil)
mockedPciUtils.On("EnableArpAndNdiscNotify", mock.AnythingOfType("string")).Return(nil)
sm := sriovManager{nLink: mocked, utils: mockedPciUtils}
macAddr, err := sm.SetupVF(netconf, podifName, contID, targetNetNS)
macAddr, err := sm.SetupVF(netconf, podifName, targetNetNS)
Expect(err).NotTo(HaveOccurred())
Expect(macAddr).To(Equal("6e:16:06:0e:b7:e9"))
})
Expand Down Expand Up @@ -127,7 +125,7 @@ var _ = Describe("Sriov", func() {
mocked.On("LinkSetUp", fakeLink).Return(nil)
mockedPciUtils.On("EnableArpAndNdiscNotify", mock.AnythingOfType("string")).Return(nil)
sm := sriovManager{nLink: mocked, utils: mockedPciUtils}
macAddr, err := sm.SetupVF(netconf, podifName, contID, targetNetNS)
macAddr, err := sm.SetupVF(netconf, podifName, targetNetNS)
Expect(err).NotTo(HaveOccurred())
Expect(macAddr).To(Equal(netconf.MAC))
mocked.AssertExpectations(t)
Expand All @@ -137,13 +135,11 @@ var _ = Describe("Sriov", func() {
Context("Checking ReleaseVF function", func() {
var (
podifName string
contID string
netconf *sriovtypes.NetConf
)

BeforeEach(func() {
podifName = "net1"
contID = "dummycid"
netconf = &sriovtypes.NetConf{
Master: "enp175s0f1",
DeviceID: "0000:af:06.0",
Expand Down Expand Up @@ -171,21 +167,19 @@ var _ = Describe("Sriov", func() {
mocked.On("LinkSetName", fakeLink, netconf.OrigVfState.HostIFName).Return(nil)
mocked.On("LinkSetNsFd", fakeLink, mock.AnythingOfType("int")).Return(nil)
sm := sriovManager{nLink: mocked}
err = sm.ReleaseVF(netconf, podifName, contID, targetNetNS)
err = sm.ReleaseVF(netconf, podifName, targetNetNS)
Expect(err).NotTo(HaveOccurred())
mocked.AssertExpectations(t)
})
})
Context("Checking ReleaseVF function - restore config", func() {
var (
podifName string
contID string
netconf *sriovtypes.NetConf
)

BeforeEach(func() {
podifName = "net1"
contID = "dummycid"
netconf = &sriovtypes.NetConf{
Master: "enp175s0f1",
DeviceID: "0000:af:06.0",
Expand Down Expand Up @@ -218,7 +212,7 @@ var _ = Describe("Sriov", func() {
Expect(err).NotTo(HaveOccurred())
mocked.On("LinkSetHardwareAddr", fakeLink, origEffMac).Return(nil)
sm := sriovManager{nLink: mocked}
err = sm.ReleaseVF(netconf, podifName, contID, targetNetNS)
err = sm.ReleaseVF(netconf, podifName, targetNetNS)
Expect(err).NotTo(HaveOccurred())
mocked.AssertExpectations(t)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/pci_allocator_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package utils

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/containernetworking/plugins/pkg/ns"
Expand Down
12 changes: 4 additions & 8 deletions pkg/utils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ func createSymlinks(link, target string) error {
if err := os.MkdirAll(target, 0755); err != nil {
return err
}
if err := os.Symlink(target, link); err != nil {
return err
}
return nil

return os.Symlink(target, link)
}

// RemoveTmpSysFs removes mocked sysfs
Expand All @@ -134,8 +132,6 @@ func RemoveTmpSysFs() error {
if err = ts.originalRoot.Close(); err != nil {
return err
}
if err = os.RemoveAll(ts.dirRoot); err != nil {
return err
}
return nil

return os.RemoveAll(ts.dirRoot)
}
6 changes: 1 addition & 5 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,7 @@ func SaveNetConf(cid, dataDir, podIfName string, conf interface{}) error {
cRef := strings.Join(s, "-")

// save the rendered netconf for cmdDel
if err = saveScratchNetConf(cRef, dataDir, netConfBytes); err != nil {
return err
}

return nil
return saveScratchNetConf(cRef, dataDir, netConfBytes)
}

func saveScratchNetConf(containerID, dataDir string, netconf []byte) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package utils
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down