ci(lint): setup golangci-lint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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"))
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -3,10 +3,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSample(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user