Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
defo89 committed Apr 12, 2024
1 parent ea6bdb5 commit 63ddf51
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
4 changes: 0 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ linters-settings:
check-type-assertions: true
exclude-functions:
- netlink.RouteGet
- viper.BindPFlags
- rand.Seed
- fmt.Errorf
- wg
forbidigo:
forbid:
# ioutil package has been deprecated: https://github.com/golang/go/issues/42026
Expand Down
4 changes: 0 additions & 4 deletions Makefile.maker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ golangciLint:
createConfig: true
errcheckExcludes:
- netlink.RouteGet
- viper.BindPFlags
- rand.Seed
- fmt.Errorf
- wg

githubWorkflow:
ci:
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ func init() {
rootCmd.PersistentFlags().IntVar(&cfg.ArpRequestTimeoutSeconds, "arp-timeout-seconds", 1, "Timeout in seconds for node arp request")
rootCmd.PersistentFlags().StringVar(&cfg.KubeContext, "kube_context", "", "kube-context to use")
rootCmd.PersistentFlags().AddGoFlagSet(goflag.CommandLine)
_ = viper.BindPFlags(rootCmd.PersistentFlags())
err := viper.BindPFlags(rootCmd.PersistentFlags())
if err != nil {
os.Exit(1)
}

rand.Seed(time.Now().UnixNano())
cfg.RandDelay = rand.Intn(1000) + 1000
source := rand.NewSource(time.Now().UnixNano())

Check failure on line 63 in internal/cmd/command.go

View workflow job for this annotation

GitHub Actions / Build & Lint

importShadow: shadow of imported from 'sigs.k8s.io/controller-runtime/pkg/source' package 'source' (gocritic)
rng := rand.New(source)
cfg.RandDelay = rng.Intn(1000) + 1000

metrics.Registry.MustRegister(metr.SentError, metr.Error, metr.ArpResolveError, metr.SentPacketsPeer, metr.SentPackets, metr.RecvPackets, metr.CallbackDuration)
cfg.PeerList = make(map[string]conf.PeerEntry)
Expand Down
3 changes: 0 additions & 3 deletions internal/nflog/pmtud.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
golog "log"
"net"
"os"
"sync"
"time"

"github.com/florianl/go-nflog/v2"
Expand All @@ -21,8 +20,6 @@ import (
const nfBufsize = 2 * 1024 * 1024
const readBufsize = 2 * 1024 * 1024

var wg = sync.WaitGroup{}

type Controller struct {
Log logr.Logger
Cfg *config.Config
Expand Down
10 changes: 5 additions & 5 deletions internal/node/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package node

import (
"context"
"fmt"
"errors"
"strings"
"time"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

Expand Down Expand Up @@ -42,7 +42,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
var node = corev1.Node{}
err := r.Client.Get(ctx, request.NamespacedName, &node)
if err != nil {
if errors.IsNotFound(err) {
if k8serr.IsNotFound(err) {
log.Info("node not found, skip", "node", request.NamespacedName)
// Node could have been deleted
return reconcile.Result{}, nil
Expand All @@ -51,7 +51,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
return reconcile.Result{}, err
}
if len(node.Status.Addresses) == 0 {
err = fmt.Errorf("no ip found for node %s", request.Name)
err = errors.New("no ip found for node")
return reconcile.Result{}, err
}
log.Info(node.Status.Addresses[0].Address)
Expand All @@ -61,7 +61,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
}
mac, err := res.Resolve(node.Status.Addresses[0].Address)
if err != nil {
err = fmt.Errorf("could not resolve mac address for node %s", request.Name)
err = errors.New("could not resolve mac address for node")
metrics.ArpResolveError.WithLabelValues(r.Cfg.NodeName, request.Name).Inc()
return reconcile.Result{}, err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/util/interface.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package util

import (
"fmt"
"errors"
"net"
"strings"

Expand Down Expand Up @@ -29,7 +29,7 @@ func GetReplicationInterface(cfg *config.Config, log logr.Logger) error {
}
}
}
err = fmt.Errorf("no interface found with names: %v", cfg.InterfaceNames)
err = errors.New("no configured interface found")
log.Error(err, "error getting replication interface")
return err
}
Expand All @@ -48,7 +48,7 @@ func GetDefaultInterface(cfg *config.Config, log logr.Logger) error {
return err
}
if len(route) == 0 {
err := fmt.Errorf("no default route found")
err := errors.New("no default route found")
log.Error(err, "error getting default route")
return err
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func GetInterfaceIP(name string, log logr.Logger) (string, error) {
}
return ip.String(), nil
}
err = fmt.Errorf("%s is not connected to the network", name)
err = errors.New("Interface is not connected to the network")

Check failure on line 96 in internal/util/interface.go

View workflow job for this annotation

GitHub Actions / Build & Lint

ST1005: error strings should not be capitalized (stylecheck)
log.Error(err, "error finding interface ip")
return "", err
}

0 comments on commit 63ddf51

Please sign in to comment.