mechanical: fix lint errors

Upgraded golangci-lint, some new errors appeared.

Signed-off-by: Casey Callendrello <c1@caseyc.net>
This commit is contained in:
Casey Callendrello
2025-04-02 15:38:41 +02:00
parent a8d8d0488c
commit 282f0a4f6e
6 changed files with 15 additions and 17 deletions

View File

@@ -38,7 +38,7 @@ var _ = Describe("Link", func() {
var (
hostNetNS ns.NetNS
containerNetNS ns.NetNS
ifaceCounter int = 0
ifaceCounter = 0
hostVeth net.Interface
containerVeth net.Interface
hostVethName string

View File

@@ -385,7 +385,7 @@ func checkLinkExistsWithBackoff(ctx context.Context, linkName string) (bool, err
func checkLinkByName(linkName string) (bool, error) {
_, err := netlinksafe.LinkByName(linkName)
if err != nil {
var linkNotFoundErr *netlink.LinkNotFoundError = &netlink.LinkNotFoundError{}
linkNotFoundErr := &netlink.LinkNotFoundError{}
if errors.As(err, linkNotFoundErr) {
return false, nil
}

View File

@@ -511,10 +511,7 @@ func calcGatewayIP(ipn *net.IPNet) net.IP {
}
func setupBridge(n *NetConf) (*netlink.Bridge, *current.Interface, error) {
vlanFiltering := false
if n.Vlan != 0 || n.VlanTrunk != nil {
vlanFiltering = true
}
vlanFiltering := n.Vlan != 0 || n.VlanTrunk != nil
// create bridge if necessary
br, err := ensureBridge(n.BrName, n.MTU, n.PromiscMode, vlanFiltering)
if err != nil {

View File

@@ -345,7 +345,7 @@ func newResolvConf() (string, error) {
}
defer f.Close()
name := f.Name()
_, err = f.WriteString(fmt.Sprintf("nameserver %s", NAMESERVER))
_, err = fmt.Fprintf(f, "nameserver %s", NAMESERVER)
return name, err
}
@@ -1834,13 +1834,13 @@ var _ = Describe("bridge Operations", func() {
})
var (
correctID int = 10
correctMinID int = 100
correctMaxID int = 105
incorrectMinID int = 1000
incorrectMaxID int = 100
overID int = 5000
negativeID int = -1
correctID = 10
correctMinID = 100
correctMaxID = 105
incorrectMinID = 1000
incorrectMaxID = 100
overID = 5000
negativeID = -1
)
DescribeTable(

View File

@@ -37,9 +37,10 @@ import (
func findChains(chains []string) (bool, bool) {
var foundAdmin, foundPriv bool
for _, ch := range chains {
if ch == "CNI-ADMIN" {
switch ch {
case "CNI-ADMIN":
foundAdmin = true
} else if ch == "CNI-FORWARD" {
case "CNI-FORWARD":
foundPriv = true
}
}

View File

@@ -86,7 +86,7 @@ func createSysctlAllowFile(sysctls []string) error {
return err
}
for _, sysctl := range sysctls {
_, err = f.WriteString(fmt.Sprintf("%s\n", sysctl))
_, err = fmt.Fprintln(f, sysctl)
if err != nil {
return err
}