enable gocritic linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -51,10 +51,11 @@ type Net struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
BrName string `json:"bridge"`
|
||||
IPAM *allocator.IPAMConfig `json:"ipam"`
|
||||
//RuntimeConfig struct { // The capability arg
|
||||
// RuntimeConfig struct { // The capability arg
|
||||
// IPRanges []RangeSet `json:"ipRanges,omitempty"`
|
||||
//} `json:"runtimeConfig,omitempty"`
|
||||
//Args *struct {
|
||||
// Args *struct {
|
||||
// } `json:"runtimeConfig,omitempty"`
|
||||
|
||||
// A *IPAMArgs `json:"cni"`
|
||||
DNS types.DNS `json:"dns"`
|
||||
RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
|
||||
@@ -1497,11 +1498,12 @@ func (tester *testerV01xOr02x) cmdDelTest(tc testCase, dataDir string) {
|
||||
err := testutils.CmdDelWithArgs(tester.args, func() error {
|
||||
return cmdDel(tester.args)
|
||||
})
|
||||
if expect020DelError(tc) {
|
||||
switch {
|
||||
case expect020DelError(tc):
|
||||
Expect(err).To(MatchError(tc.DelErr020))
|
||||
} else if expect010DelError(tc) {
|
||||
case expect010DelError(tc):
|
||||
Expect(err).To(MatchError(tc.DelErr010))
|
||||
} else {
|
||||
default:
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -322,10 +322,11 @@ func getLink(devname, hwaddr, kernelpath, pciaddr string) (netlink.Link, error)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to list node links: %v", err)
|
||||
}
|
||||
switch {
|
||||
|
||||
if len(devname) > 0 {
|
||||
case len(devname) > 0:
|
||||
return netlink.LinkByName(devname)
|
||||
} else if len(hwaddr) > 0 {
|
||||
case len(hwaddr) > 0:
|
||||
hwAddr, err := net.ParseMAC(hwaddr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse MAC address %q: %v", hwaddr, err)
|
||||
@@ -336,7 +337,7 @@ func getLink(devname, hwaddr, kernelpath, pciaddr string) (netlink.Link, error)
|
||||
return link, nil
|
||||
}
|
||||
}
|
||||
} else if len(kernelpath) > 0 {
|
||||
case len(kernelpath) > 0:
|
||||
if !filepath.IsAbs(kernelpath) || !strings.HasPrefix(kernelpath, "/sys/devices/") {
|
||||
return nil, fmt.Errorf("kernel device path %q must be absolute and begin with /sys/devices/", kernelpath)
|
||||
}
|
||||
@@ -355,7 +356,7 @@ func getLink(devname, hwaddr, kernelpath, pciaddr string) (netlink.Link, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if len(pciaddr) > 0 {
|
||||
case len(pciaddr) > 0:
|
||||
netDir := filepath.Join(sysBusPCI, pciaddr, "net")
|
||||
if _, err := os.Lstat(netDir); err != nil {
|
||||
virtioNetDir := filepath.Join(sysBusPCI, pciaddr, "virtio*", "net")
|
||||
|
||||
@@ -48,10 +48,10 @@ type Net struct {
|
||||
Master string `json:"master"`
|
||||
Mode string `json:"mode"`
|
||||
IPAM *allocator.IPAMConfig `json:"ipam"`
|
||||
//RuntimeConfig struct { // The capability arg
|
||||
// RuntimeConfig struct { // The capability arg
|
||||
// IPRanges []RangeSet `json:"ipRanges,omitempty"`
|
||||
//} `json:"runtimeConfig,omitempty"`
|
||||
//Args *struct {
|
||||
// Args *struct {
|
||||
// } `json:"runtimeConfig,omitempty"`
|
||||
// A *IPAMArgs `json:"cni"`
|
||||
DNS types.DNS `json:"dns"`
|
||||
RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
|
||||
|
||||
@@ -173,14 +173,15 @@ func createLinkWithNetlink(tmpName string, mtu int, nsFd int, multiqueue bool, m
|
||||
}
|
||||
|
||||
func createLink(tmpName string, conf *NetConf, netns ns.NetNS) error {
|
||||
if conf.SelinuxContext != "" {
|
||||
switch {
|
||||
case conf.SelinuxContext != "":
|
||||
if err := selinux.SetExecLabel(conf.SelinuxContext); err != nil {
|
||||
return fmt.Errorf("failed set socket label: %v", err)
|
||||
}
|
||||
return createTapWithIptool(tmpName, conf.MTU, conf.MultiQueue, conf.Mac, conf.Owner, conf.Group)
|
||||
} else if conf.Owner == nil || conf.Group == nil {
|
||||
case conf.Owner == nil || conf.Group == nil:
|
||||
return createTapWithIptool(tmpName, conf.MTU, conf.MultiQueue, conf.Mac, conf.Owner, conf.Group)
|
||||
} else {
|
||||
default:
|
||||
return createLinkWithNetlink(tmpName, conf.MTU, int(netns.Fd()), conf.MultiQueue, conf.Mac, conf.Owner, conf.Group)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ func validateCniContainerInterface(intf current.Interface, masterIndex int, vlan
|
||||
}
|
||||
|
||||
// TODO This works when unit testing via cnitool; fails with ./test.sh
|
||||
//if masterIndex != vlan.Attrs().ParentIndex {
|
||||
// if masterIndex != vlan.Attrs().ParentIndex {
|
||||
// return fmt.Errorf("Container vlan Master %d does not match expected value: %d", vlan.Attrs().ParentIndex, masterIndex)
|
||||
//}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user