ci(lint): setup golangci-lint

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2023-02-28 22:27:25 +00:00
parent 86e39cfe3c
commit d12b81dec5
110 changed files with 419 additions and 479 deletions

View File

@ -22,6 +22,9 @@ import (
"os"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/vishvananda/netlink"
"github.com/containernetworking/cni/pkg/invoke"
@ -30,10 +33,6 @@ import (
types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
func buildOneConfig(name, cniVersion string, orig *PluginConf, prevResult types.Result) (*PluginConf, []byte, error) {
@ -78,7 +77,6 @@ func buildOneConfig(name, cniVersion string, orig *PluginConf, prevResult types.
}
return conf, newBytes, nil
}
var _ = Describe("bandwidth test", func() {
@ -221,7 +219,6 @@ var _ = Describe("bandwidth test", func() {
Expect(qdiscs[0].(*netlink.Tbf).Limit).To(Equal(uint32(1)))
return nil
})).To(Succeed())
})
It(fmt.Sprintf("[%s] does not apply ingress when disabled", ver), func() {
@ -289,7 +286,6 @@ var _ = Describe("bandwidth test", func() {
return nil
})).To(Succeed())
})
It(fmt.Sprintf("[%s] does not apply egress when disabled", ver), func() {
@ -359,7 +355,6 @@ var _ = Describe("bandwidth test", func() {
Expect(qdiscs[0].(*netlink.Tbf).Limit).To(Equal(uint32(35)))
return nil
})).To(Succeed())
})
It(fmt.Sprintf("[%s] fails an invalid ingress config", ver), func() {
@ -507,7 +502,6 @@ var _ = Describe("bandwidth test", func() {
Expect(qdiscs[0].(*netlink.Tbf).Limit).To(Equal(uint32(1)))
return nil
})).To(Succeed())
})
It(fmt.Sprintf("[%s] should apply static config when both static config and runtime config exist", ver), func() {
@ -620,7 +614,6 @@ var _ = Describe("bandwidth test", func() {
return nil
})).To(Succeed())
})
})
@ -730,7 +723,6 @@ var _ = Describe("bandwidth test", func() {
Expect(qdiscs[0].(*netlink.Tbf).Limit).To(Equal(uint32(1)))
return nil
})).To(Succeed())
})
It(fmt.Sprintf("[%s] should fail when container interface has no veth peer", ver), func() {

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@ -24,14 +24,13 @@ import (
"strings"
"testing"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/pkg/ns"
)
func TestTBF(t *testing.T) {

View File

@ -19,9 +19,9 @@ import (
"net"
"syscall"
"github.com/containernetworking/plugins/pkg/ip"
"github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/pkg/ip"
)
const latencyInMillis = 25
@ -34,7 +34,6 @@ func CreateIfb(ifbDeviceName string, mtu int) error {
MTU: mtu,
},
})
if err != nil {
return fmt.Errorf("adding link: %s", err)
}
@ -147,10 +146,6 @@ func createTBF(rateInBits, burstInBits uint64, linkIndex int) error {
return nil
}
func tick2Time(tick uint32) uint32 {
return uint32(float64(tick) / float64(netlink.TickInUsec()))
}
func time2Tick(time uint32) uint32 {
return uint32(float64(time) * float64(netlink.TickInUsec()))
}

View File

@ -25,24 +25,25 @@ import (
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ip"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/utils"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)
const maxIfbDeviceLength = 15
const ifbDevicePrefix = "bwp"
const (
maxIfbDeviceLength = 15
ifbDevicePrefix = "bwp"
)
// BandwidthEntry corresponds to a single entry in the bandwidth argument,
// see CONVENTIONS.md
type BandwidthEntry struct {
IngressRate uint64 `json:"ingressRate"` //Bandwidth rate in bps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set
IngressBurst uint64 `json:"ingressBurst"` //Bandwidth burst in bits for traffic through container. 0 for no limit. If ingressBurst is set, ingressRate must also be set
IngressRate uint64 `json:"ingressRate"` // Bandwidth rate in bps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set
IngressBurst uint64 `json:"ingressBurst"` // Bandwidth burst in bits for traffic through container. 0 for no limit. If ingressBurst is set, ingressRate must also be set
EgressRate uint64 `json:"egressRate"` //Bandwidth rate in bps for traffic through container. 0 for no limit. If egressRate is set, egressBurst must also be set
EgressBurst uint64 `json:"egressBurst"` //Bandwidth burst in bits for traffic through container. 0 for no limit. If egressBurst is set, egressRate must also be set
EgressRate uint64 `json:"egressRate"` // Bandwidth rate in bps for traffic through container. 0 for no limit. If egressRate is set, egressBurst must also be set
EgressBurst uint64 `json:"egressBurst"` // Bandwidth burst in bits for traffic through container. 0 for no limit. If egressBurst is set, egressRate must also be set
}
func (bw *BandwidthEntry) isZero() bool {
@ -92,7 +93,6 @@ func parseConfig(stdin []byte) (*PluginConf, error) {
}
return &conf, nil
}
func getBandwidth(conf *PluginConf) *BandwidthEntry {

View File

@ -26,7 +26,6 @@ import (
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)

View File

@ -22,16 +22,15 @@ import (
"sync"
"syscall"
"github.com/godbus/dbus/v5"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/skel"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/godbus/dbus/v5"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
const ifname = "eth0"

View File

@ -22,12 +22,13 @@ import (
"path/filepath"
"strings"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/containernetworking/cni/libcni"
types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
// The integration tests expect the "firewall" binary to be present in $PATH.

View File

@ -19,6 +19,11 @@ import (
"fmt"
"strings"
"github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vishvananda/netlink"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/040"
@ -26,13 +31,6 @@ import (
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/vishvananda/netlink"
"github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func findChains(chains []string) (bool, bool) {

View File

@ -15,10 +15,10 @@
package main
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"testing"
)
func TestFirewall(t *testing.T) {

View File

@ -18,8 +18,9 @@ import (
"fmt"
"strings"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/godbus/dbus/v5"
current "github.com/containernetworking/cni/pkg/types/100"
)
const (

View File

@ -19,9 +19,10 @@ package main
import (
"fmt"
"github.com/coreos/go-iptables/iptables"
types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/utils"
"github.com/coreos/go-iptables/iptables"
)
func setupIngressPolicy(conf *FirewallNetConf, prevResult *types100.Result) error {

View File

@ -21,9 +21,10 @@ import (
"fmt"
"net"
"github.com/coreos/go-iptables/iptables"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/utils"
"github.com/coreos/go-iptables/iptables"
)
func getPrivChainRules(ip string) [][]string {
@ -211,7 +212,6 @@ type iptablesBackend struct {
protos map[iptables.Protocol]*iptables.IPTables
privChainName string
adminChainName string
ifName string
}
// iptablesBackend implements the FirewallBackend interface

View File

@ -18,9 +18,10 @@ import (
"fmt"
"strings"
"github.com/containernetworking/plugins/pkg/utils"
"github.com/coreos/go-iptables/iptables"
"github.com/mattn/go-shellwords"
"github.com/containernetworking/plugins/pkg/utils"
)
type chain struct {
@ -36,7 +37,6 @@ type chain struct {
// setup idempotently creates the chain. It will not error if the chain exists.
func (c *chain) setup(ipt *iptables.IPTables) error {
err := utils.EnsureChain(ipt, c.table, c.name)
if err != nil {
return err
@ -103,7 +103,6 @@ func (c *chain) teardown(ipt *iptables.IPTables) error {
// check the chain.
func (c *chain) check(ipt *iptables.IPTables) error {
exists, err := utils.ChainExists(ipt, c.table, c.name)
if err != nil {
return err

View File

@ -20,11 +20,12 @@ import (
"runtime"
"sync"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
)
const TABLE = "filter" // We'll monkey around here
@ -37,7 +38,6 @@ var _ = Describe("chain tests", func() {
var cleanup func()
beforeEach := func() {
// Save a reference to the original namespace,
// Add a new NS
currNs, err := ns.GetCurrentNS()
@ -83,7 +83,6 @@ var _ = Describe("chain tests", func() {
ipt.DeleteChain(TABLE, tlChainName)
currNs.Set()
}
}
It("creates and destroys a chain", func() {
@ -169,7 +168,6 @@ var _ = Describe("chain tests", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(rules)).To(Equal(3))
})
It("deletes chains idempotently", func() {
@ -233,6 +231,5 @@ var _ = Describe("chain tests", func() {
Fail("Chain was not deleted")
}
}
})
})

View File

@ -31,12 +31,12 @@ import (
"log"
"net"
"golang.org/x/sys/unix"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"golang.org/x/sys/unix"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)

View File

@ -21,10 +21,11 @@ import (
"strconv"
"strings"
"github.com/containernetworking/plugins/pkg/utils"
"github.com/containernetworking/plugins/pkg/utils/sysctl"
"github.com/coreos/go-iptables/iptables"
"github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/pkg/utils"
"github.com/containernetworking/plugins/pkg/utils/sysctl"
)
// This creates the chains to be added to iptables. The basic structure is

View File

@ -24,15 +24,16 @@ import (
"os/exec"
"path/filepath"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/vishvananda/netlink"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
)
func makeConfig(ver string) *libcni.NetworkConfigList {

View File

@ -21,15 +21,14 @@ import (
"path/filepath"
"strconv"
"strings"
"github.com/containernetworking/plugins/pkg/ns"
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"testing"
"github.com/containernetworking/plugins/pkg/ns"
)
func TestPortmap(t *testing.T) {

View File

@ -17,10 +17,10 @@ package main
import (
"fmt"
"github.com/containernetworking/cni/pkg/types"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/containernetworking/cni/pkg/types"
)
var _ = Describe("portmapping configuration", func() {
@ -202,18 +202,22 @@ var _ = Describe("portmapping configuration", func() {
fillDnatRules(&ch, conf, *n)
Expect(ch.entryRules).To(Equal([][]string{
{"-m", "comment", "--comment",
{
"-m", "comment", "--comment",
fmt.Sprintf("dnat name: \"test\" id: \"%s\"", containerID),
"-m", "multiport",
"-p", "tcp",
"--destination-ports", "8080,8081,8083,8084,8085,8086",
"a", "b"},
{"-m", "comment", "--comment",
"a", "b",
},
{
"-m", "comment", "--comment",
fmt.Sprintf("dnat name: \"test\" id: \"%s\"", containerID),
"-m", "multiport",
"-p", "udp",
"--destination-ports", "8080,8082",
"a", "b"},
"a", "b",
},
}))
Expect(ch.rules).To(Equal([][]string{

View File

@ -32,13 +32,6 @@ func fmtIpPort(ip net.IP, port int) string {
return fmt.Sprintf("%s:%d", ip.String(), port)
}
func localhostIP(isV6 bool) string {
if isV6 {
return "::1"
}
return "127.0.0.1"
}
// getRoutableHostIF will try and determine which interface routes the container's
// traffic. This is the one on which we disable martian filtering.
func getRoutableHostIF(containerIP net.IP) string {

View File

@ -28,7 +28,6 @@ import (
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ns"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)
@ -109,7 +108,6 @@ func parseConfig(stdin []byte) (*PluginConf, error) {
// getIPCfgs finds the IPs on the supplied interface, returning as IPConfig structures
func getIPCfgs(iface string, prevResult *current.Result) ([]*current.IPConfig, error) {
if len(prevResult.IPs) == 0 {
// No IP addresses; that makes no sense. Pack it in.
return nil, fmt.Errorf("No IP addresses supplied on interface: %s", iface)
@ -276,7 +274,8 @@ func doRoutes(ipCfgs []*current.IPConfig, origRoutes []*types.Route, iface strin
Dst: &dest,
Gw: ipCfg.Gateway,
Table: table,
LinkIndex: linkIndex}
LinkIndex: linkIndex,
}
err = netlink.RouteAdd(&route)
if err != nil {
@ -350,7 +349,6 @@ func cmdDel(args *skel.CmdArgs) error {
// Tidy up the rules for the deleted interface
func tidyRules(iface string) error {
// We keep on going on rule deletion error, but return the last failure.
var errReturn error

View File

@ -19,15 +19,14 @@ import (
"log"
"net"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
)
// Structures specifying state at start.
@ -114,7 +113,6 @@ func readback(targetNs ns.NetNS, devNames []string) (netStatus, error) {
routes, err := netlink.RouteListFiltered(netlink.FAMILY_ALL,
routeFilter,
netlink.RT_FILTER_OIF|netlink.RT_FILTER_TABLE)
if err != nil {
return err
}
@ -218,7 +216,8 @@ func createDefaultStatus() netStatus {
return netStatus{
Devices: devs,
Rules: rules}
Rules: rules,
}
}
var _ = Describe("sbr test", func() {
@ -293,7 +292,8 @@ var _ = Describe("sbr test", func() {
netlink.Route{
Gw: net.IPv4(192, 168, 1, 1),
Table: 100,
LinkIndex: expNet1.Routes[0].LinkIndex})
LinkIndex: expNet1.Routes[0].LinkIndex,
})
Expect(len(newStatus.Rules)).To(Equal(1))
Expect(newStatus.Rules[0].Table).To(Equal(100))
@ -367,7 +367,8 @@ var _ = Describe("sbr test", func() {
preStatus.Devices[1].Routes = append(preStatus.Devices[1].Routes,
netlink.Route{
Gw: net.IPv4(192, 168, 1, 1),
LinkIndex: routes[0].LinkIndex})
LinkIndex: routes[0].LinkIndex,
})
err := setup(targetNs, preStatus)
Expect(err).NotTo(HaveOccurred())
@ -480,7 +481,8 @@ var _ = Describe("sbr test", func() {
netlink.Route{
Dst: expNet1.Routes[i].Dst,
Table: 101,
LinkIndex: expNet1.Routes[i].LinkIndex})
LinkIndex: expNet1.Routes[i].LinkIndex,
})
} else {
// All 192.168.1.x routes expected in table 100
expNet1.Routes[i].Table = 100
@ -491,13 +493,15 @@ var _ = Describe("sbr test", func() {
netlink.Route{
Gw: net.IPv4(192, 168, 1, 1),
Table: 100,
LinkIndex: expNet1.Routes[0].LinkIndex})
LinkIndex: expNet1.Routes[0].LinkIndex,
})
expNet1.Routes = append(expNet1.Routes,
netlink.Route{
Gw: net.IPv4(192, 168, 101, 1),
Table: 101,
LinkIndex: expNet1.Routes[0].LinkIndex})
LinkIndex: expNet1.Routes[0].LinkIndex,
})
// 2 Rules will be created for each IP address. (100, 101)
Expect(len(newStatus.Rules)).To(Equal(2))
@ -514,7 +518,6 @@ var _ = Describe("sbr test", func() {
devEth0 := newStatus.Devices[1]
Expect(equalRoutes(expNet1.Routes, devNet1.Routes)).To(BeTrue())
Expect(equalRoutes(expEth0.Routes, devEth0.Routes)).To(BeTrue())
})
It("fails with CNI spec versions that don't support plugin chaining", func() {
@ -537,5 +540,4 @@ var _ = Describe("sbr test", func() {
_, _, err = testutils.CmdAddWithArgs(args, func() error { return cmdAdd(args) })
Expect(err).To(MatchError("This plugin must be called as chained plugin"))
})
})

View File

@ -3,10 +3,10 @@
package main
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"testing"
)
func TestSample(t *testing.T) {

View File

@ -35,14 +35,15 @@ import (
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ns"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)
const defaultDataDir = "/run/cni/tuning"
const defaultAllowlistDir = "/etc/cni/tuning/"
const defaultAllowlistFile = "allowlist.conf"
const (
defaultDataDir = "/run/cni/tuning"
defaultAllowlistDir = "/etc/cni/tuning/"
defaultAllowlistFile = "allowlist.conf"
)
// TuningConf represents the network tuning configuration.
type TuningConf struct {
@ -225,7 +226,7 @@ func createBackup(ifName, containerID, backupPath string, tuningConf *TuningConf
}
if _, err := os.Stat(backupPath); os.IsNotExist(err) {
if err = os.MkdirAll(backupPath, 0600); err != nil {
if err = os.MkdirAll(backupPath, 0o600); err != nil {
return fmt.Errorf("failed to create backup directory: %v", err)
}
}
@ -234,7 +235,7 @@ func createBackup(ifName, containerID, backupPath string, tuningConf *TuningConf
if err != nil {
return fmt.Errorf("failed to marshall data for %q: %v", ifName, err)
}
if err = os.WriteFile(path.Join(backupPath, containerID+"_"+ifName+".json"), data, 0600); err != nil {
if err = os.WriteFile(path.Join(backupPath, containerID+"_"+ifName+".json"), data, 0o600); err != nil {
return fmt.Errorf("failed to save file %s.json: %v", ifName, err)
}
@ -348,7 +349,7 @@ func cmdAdd(args *skel.CmdArgs) error {
return fmt.Errorf("invalid net sysctl key: %q", key)
}
content := []byte(value)
err := os.WriteFile(fileName, content, 0644)
err := os.WriteFile(fileName, content, 0o644)
if err != nil {
return err
}
@ -507,7 +508,7 @@ func validateSysctlConf(tuningConf *TuningConf) error {
if !isPresent {
return nil
}
for sysctl, _ := range tuningConf.SysCtl {
for sysctl := range tuningConf.SysCtl {
match, err := contains(sysctl, allowlist)
if err != nil {
return err

View File

@ -15,10 +15,10 @@
package main
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"testing"
)
func TestTuning(t *testing.T) {

View File

@ -21,17 +21,16 @@ import (
"os"
"path/filepath"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"golang.org/x/sys/unix"
"github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func buildOneConfig(name, cniVersion string, orig *TuningConf, prevResult types.Result) (*TuningConf, []byte, error) {
@ -74,11 +73,10 @@ func buildOneConfig(name, cniVersion string, orig *TuningConf, prevResult types.
}
return conf, newBytes, nil
}
func createSysctlAllowFile(sysctls []string) error {
err := os.MkdirAll(defaultAllowlistDir, 0755)
err := os.MkdirAll(defaultAllowlistDir, 0o755)
if err != nil {
return err
}

View File

@ -24,7 +24,6 @@ import (
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ns"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)

View File

@ -15,10 +15,10 @@
package main
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"testing"
)
func TestVRF(t *testing.T) {

View File

@ -18,16 +18,15 @@ import (
"encoding/json"
"fmt"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vishvananda/netlink"
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
"github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func buildOneConfig(name, cniVersion string, orig *VRFNetConf, prevResult types.Result) (*VRFNetConf, []byte, error) {
@ -70,7 +69,6 @@ func buildOneConfig(name, cniVersion string, orig *VRFNetConf, prevResult types.
}
return conf, newBytes, nil
}
var _ = Describe("vrf plugin", func() {
@ -343,7 +341,6 @@ var _ = Describe("vrf plugin", func() {
})
Expect(err).NotTo(HaveOccurred())
})
},
Entry("added to the same vrf", VRF0Name, VRF0Name, "10.0.0.2/24", "10.0.0.3/24"),
Entry("added to different vrfs", VRF0Name, VRF1Name, "10.0.0.2/24", "10.0.0.3/24"),
@ -606,7 +603,6 @@ var _ = Describe("vrf plugin", func() {
})
Expect(err).NotTo(HaveOccurred())
})
})
var _ = Describe("unit tests", func() {
@ -703,10 +699,3 @@ func checkInterfaceOnVRF(vrfName, intfName string) {
Expect(err).NotTo(HaveOccurred())
Expect(master.Attrs().Name).To(Equal(vrfName))
}
func checkLinkHasNoMaster(intfName string) {
link, err := netlink.LinkByName(intfName)
Expect(err).NotTo(HaveOccurred())
masterIndx := link.Attrs().MasterIndex
Expect(masterIndx).To(Equal(0))
}