Fix revive linter errors

Golangci-lint is now running version 1.52.1. This introduced some errors.

Signed-off-by: Marcelo Guerrero Viveros <marguerr@redhat.com>
This commit is contained in:
Marcelo Guerrero Viveros
2023-03-24 21:02:23 +01:00
parent 3bc00017e3
commit d71d0f2da1
33 changed files with 87 additions and 159 deletions

View File

@ -116,12 +116,12 @@ func getBackend(conf *FirewallNetConf) (FirewallBackend, error) {
case "iptables":
return newIptablesBackend(conf)
case "firewalld":
return newFirewalldBackend(conf)
return newFirewalldBackend()
}
// Default to firewalld if it's running
if isFirewalldRunning() {
return newFirewalldBackend(conf)
return newFirewalldBackend()
}
// Otherwise iptables
@ -175,11 +175,7 @@ func cmdDel(args *skel.CmdArgs) error {
return err
}
if err := teardownIngressPolicy(conf, result); err != nil {
return err
}
return nil
return teardownIngressPolicy(conf)
}
func main() {
@ -202,9 +198,5 @@ func cmdCheck(args *skel.CmdArgs) error {
return err
}
if err := backend.Check(conf, result); err != nil {
return err
}
return nil
return backend.Check(conf, result)
}

View File

@ -71,7 +71,7 @@ func isFirewalldRunning() bool {
return true
}
func newFirewalldBackend(conf *FirewallNetConf) (FirewallBackend, error) {
func newFirewalldBackend() (FirewallBackend, error) {
conn, err := getConn()
if err != nil {
return nil, err

View File

@ -62,7 +62,7 @@ func setupIngressPolicySameBridge(conf *FirewallNetConf, prevResult *types100.Re
return nil
}
func teardownIngressPolicy(conf *FirewallNetConf, prevResult *types100.Result) error {
func teardownIngressPolicy(conf *FirewallNetConf) error {
switch conf.IngressPolicy {
case "", IngressPolicyOpen:
// NOP
@ -151,11 +151,7 @@ func setupIsolationChains(ipt *iptables.IPTables, bridgeName string) error {
return err
}
stage2Return := withDefaultComment([]string{"-j", "RETURN"})
if err := utils.InsertUnique(ipt, filterTableName, stage2Chain, false, stage2Return); err != nil {
return err
}
return nil
return utils.InsertUnique(ipt, filterTableName, stage2Chain, false, stage2Return)
}
func isolationStage1BridgeRule(bridgeName, stage2Chain string) []string {

View File

@ -74,11 +74,7 @@ func (ib *iptablesBackend) setupChains(ipt *iptables.IPTables) error {
}
// Ensure our admin override chain rule exists in our private chain
if err := ensureFirstChainRule(ipt, ib.privChainName, adminRule); err != nil {
return err
}
return nil
return ensureFirstChainRule(ipt, ib.privChainName, adminRule)
}
func protoForIP(ip net.IPNet) iptables.Protocol {
@ -88,7 +84,7 @@ func protoForIP(ip net.IPNet) iptables.Protocol {
return iptables.ProtocolIPv6
}
func (ib *iptablesBackend) addRules(conf *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
func (ib *iptablesBackend) addRules(_ *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
rules := make([][]string, 0)
for _, ip := range result.IPs {
if protoForIP(ip.Address) == proto {
@ -120,7 +116,7 @@ func (ib *iptablesBackend) addRules(conf *FirewallNetConf, result *current.Resul
return nil
}
func (ib *iptablesBackend) delRules(conf *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
func (ib *iptablesBackend) delRules(_ *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
rules := make([][]string, 0)
for _, ip := range result.IPs {
if protoForIP(ip.Address) == proto {
@ -135,7 +131,7 @@ func (ib *iptablesBackend) delRules(conf *FirewallNetConf, result *current.Resul
return nil
}
func (ib *iptablesBackend) checkRules(conf *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
func (ib *iptablesBackend) checkRules(_ *FirewallNetConf, result *current.Result, ipt *iptables.IPTables, proto iptables.Protocol) error {
rules := make([][]string, 0)
for _, ip := range result.IPs {
if protoForIP(ip.Address) == proto {