enable revive linter

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2023-03-12 11:25:53 +01:00
parent 79f524689c
commit a02bf4b463
19 changed files with 68 additions and 60 deletions

View File

@ -299,8 +299,8 @@ func ensureBridge(brName string, mtu int, promiscMode, vlanFiltering bool) (*net
return br, nil
}
func ensureVlanInterface(br *netlink.Bridge, vlanId int) (netlink.Link, error) {
name := fmt.Sprintf("%s.%d", br.Name, vlanId)
func ensureVlanInterface(br *netlink.Bridge, vlanID int) (netlink.Link, error) {
name := fmt.Sprintf("%s.%d", br.Name, vlanID)
brGatewayVeth, err := netlink.LinkByName(name)
if err != nil {
@ -313,7 +313,7 @@ func ensureVlanInterface(br *netlink.Bridge, vlanId int) (netlink.Link, error) {
return nil, fmt.Errorf("faild to find host namespace: %v", err)
}
_, brGatewayIface, err := setupVeth(hostNS, br, name, br.MTU, false, vlanId, "")
_, brGatewayIface, err := setupVeth(hostNS, br, name, br.MTU, false, vlanID, "")
if err != nil {
return nil, fmt.Errorf("faild to create vlan gateway %q: %v", name, err)
}
@ -406,7 +406,7 @@ func enableIPForward(family int) error {
}
func cmdAdd(args *skel.CmdArgs) error {
var success bool = false
success := false
n, cniVersion, err := loadNetConf(args.StdinData, args.Args)
if err != nil {
@ -420,7 +420,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}
if n.HairpinMode && n.PromiscMode {
return fmt.Errorf("cannot set hairpin mode and promiscuous mode at the same time.")
return fmt.Errorf("cannot set hairpin mode and promiscuous mode at the same time")
}
br, brInterface, err := setupBridge(n)

View File

@ -410,9 +410,9 @@ func countIPAMIPs(path string) (int, error) {
return count, nil
}
func checkVlan(vlanId int, bridgeVlanInfo []*nl.BridgeVlanInfo) bool {
func checkVlan(vlanID int, bridgeVlanInfo []*nl.BridgeVlanInfo) bool {
for _, vlan := range bridgeVlanInfo {
if vlan.Vid == uint16(vlanId) {
if vlan.Vid == uint16(vlanID) {
return true
}
}

View File

@ -35,7 +35,7 @@ import (
type NetConf struct {
types.NetConf
Master string `json:"master"`
VlanId int `json:"vlanId"`
VlanID int `json:"vlanId"`
MTU int `json:"mtu,omitempty"`
LinkContNs bool `json:"linkInContainer,omitempty"`
}
@ -53,10 +53,10 @@ func loadConf(args *skel.CmdArgs) (*NetConf, string, error) {
return nil, "", fmt.Errorf("failed to load netconf: %v", err)
}
if n.Master == "" {
return nil, "", fmt.Errorf("\"master\" field is required. It specifies the host interface name to create the VLAN for.")
return nil, "", fmt.Errorf("\"master\" field is required. It specifies the host interface name to create the VLAN for")
}
if n.VlanId < 0 || n.VlanId > 4094 {
return nil, "", fmt.Errorf("invalid VLAN ID %d (must be between 0 and 4095 inclusive)", n.VlanId)
if n.VlanID < 0 || n.VlanID > 4094 {
return nil, "", fmt.Errorf("invalid VLAN ID %d (must be between 0 and 4095 inclusive)", n.VlanID)
}
// check existing and MTU of master interface
@ -126,7 +126,7 @@ func createVlan(conf *NetConf, ifName string, netns ns.NetNS) (*current.Interfac
ParentIndex: m.Attrs().Index,
Namespace: netlink.NsFd(int(netns.Fd())),
},
VlanId: conf.VlanId,
VlanId: conf.VlanID,
}
if conf.LinkContNs {
@ -326,7 +326,7 @@ func cmdCheck(args *skel.CmdArgs) error {
// Check prevResults for ips, routes and dns against values found in the container
if err := netns.Do(func(_ ns.NetNS) error {
// Check interface against values found in the container
err := validateCniContainerInterface(contMap, m.Attrs().Index, conf.VlanId, conf.MTU)
err := validateCniContainerInterface(contMap, m.Attrs().Index, conf.VlanID, conf.MTU)
if err != nil {
return err
}
@ -348,7 +348,7 @@ func cmdCheck(args *skel.CmdArgs) error {
return nil
}
func validateCniContainerInterface(intf current.Interface, masterIndex int, vlanId int, mtu int) error {
func validateCniContainerInterface(intf current.Interface, masterIndex int, vlanID int, mtu int) error {
var link netlink.Link
var err error
@ -379,9 +379,9 @@ func validateCniContainerInterface(intf current.Interface, masterIndex int, vlan
}
}
if vlanId != vlan.VlanId {
if vlanID != vlan.VlanId {
return fmt.Errorf("Error: Tuning link %s configured promisc is %v, current value is %d",
intf.Name, vlanId, vlan.VlanId)
intf.Name, vlanID, vlan.VlanId)
}
if mtu != 0 {

View File

@ -46,7 +46,7 @@ type Net struct {
CNIVersion string `json:"cniVersion"`
Type string `json:"type,omitempty"`
Master string `json:"master"`
VlanId int `json:"vlanId"`
VlanID int `json:"vlanId"`
MTU int `json:"mtu"`
IPAM *allocator.IPAMConfig `json:"ipam"`
DNS types.DNS `json:"dns"`
@ -249,7 +249,7 @@ var _ = Describe("vlan Operations", func() {
Type: "vlan",
},
Master: masterInterface,
VlanId: 33,
VlanID: 33,
MTU: 1500,
LinkContNs: isInContainer,
}
@ -285,7 +285,7 @@ var _ = Describe("vlan Operations", func() {
Type: "vlan",
},
Master: masterInterface,
VlanId: 33,
VlanID: 33,
LinkContNs: isInContainer,
}