Skip to content

Commit

Permalink
Fix #446 - Bumped golangci v1.54.2 to v1.61.0 and corrected new lint …
Browse files Browse the repository at this point in the history
…warnings. (#447)
  • Loading branch information
PMaynard authored Nov 7, 2024
1 parent 626d526 commit 8424fa8
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 27 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linters:
- cyclop
- errname
- exhaustive
- exportloopref
- copyloopvar
- gocritic
- gofmt
- gosimple
Expand All @@ -25,6 +25,5 @@ linters-settings:
- rangeExprCopy
- rangeValCopy
- indexAlloc
- deprecatedComment
cyclop:
max-complexity: 20
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endif

LOCAL_GENERATOR_IMAGE ?= ebpf-generator:latest
CILIUM_EBPF_VERSION := v0.16.0
GOLANGCI_LINT_VERSION = v1.54.2
GOLANGCI_LINT_VERSION = v1.61.0
GO_VERSION = "1.22.4"
PROTOC_VERSION = "3.19.4"
PROTOC_GEN_GO_VERSION="v1.35.1"
Expand Down
2 changes: 1 addition & 1 deletion e2e/cluster/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (k *Kind) orderedManifests() []Deployment {

// export logs into the e2e-logs folder of the base directory.
func (k *Kind) exportLogs() env.Func {
return func(ctx context.Context, config *envconf.Config) (context.Context, error) {
return func(ctx context.Context, _ *envconf.Config) (context.Context, error) {
logsDir := path.Join(k.baseDir, logsSubDir)
log.WithField("directory", logsDir).Info("exporting cluster logs")
exe := gexe.New()
Expand Down
7 changes: 0 additions & 7 deletions pkg/agent/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func TestInterfaces_DefaultConfig(t *testing.T) {

// Allowed
for _, iface := range []string{"eth0", "br-0"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.True(t, allowed)
Expand All @@ -32,14 +31,12 @@ func TestInterfaceFilter_SelectingInterfaces_DefaultExclusion(t *testing.T) {

// Allowed
for _, iface := range []string{"eth0", "br-0"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.True(t, allowed)
}
// Not Allowed
for _, iface := range []string{"eth01", "abr-3", "lo"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.False(t, allowed)
Expand All @@ -52,14 +49,12 @@ func TestInterfaceFilter_ExclusionTakesPriority(t *testing.T) {

// Allowed
for _, iface := range []string{"eth0", "eth-10", "eth11", "br-2", "br-0"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.True(t, allowed)
}
// Not Allowed
for _, iface := range []string{"eth1", "br-1", "br-10"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.False(t, allowed)
Expand Down Expand Up @@ -94,14 +89,12 @@ func TestInterfaceFilter_InterfaceIPs(t *testing.T) {

// Allowed
for _, iface := range []string{"eth0", "eth2", "eth4"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.True(t, allowed)
}
// Not Allowed
for _, iface := range []string{"eth1", "eth3"} {
iface := iface
allowed, err := ifaces.Allowed(iface)
require.NoError(t, err)
assert.False(t, allowed)
Expand Down
6 changes: 3 additions & 3 deletions pkg/exporter/grpc_proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestIPv4GRPCProto_ExportFlows_AgentIP(t *testing.T) {
case rs = <-serverOut:
assert.Failf(t, "shouldn't have received any flow", "Got: %#v", rs)
default:
//ok!
// ok!
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func TestIPv6GRPCProto_ExportFlows_AgentIP(t *testing.T) {
case rs = <-serverOut:
assert.Failf(t, "shouldn't have received any flow", "Got: %#v", rs)
default:
//ok!
// ok!
}
}

Expand Down Expand Up @@ -141,6 +141,6 @@ func TestGRPCProto_SplitLargeMessages(t *testing.T) {
case rs = <-serverOut:
assert.Failf(t, "shouldn't have received any flow", "Got: %#v", rs)
default:
//ok!
// ok!
}
}
4 changes: 2 additions & 2 deletions pkg/grpc/flow/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestGRPCCommunication(t *testing.T) {
case rs = <-serverOut:
assert.Failf(t, "shouldn't have received any flow", "Got: %#v", rs)
default:
//ok!
// ok!
}
}

Expand All @@ -102,7 +102,7 @@ func TestConstructorOptions(t *testing.T) {
WithGRPCServerOptions(grpc.UnaryInterceptor(func(
ctx context.Context,
req interface{},
info *grpc.UnaryServerInfo,
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (resp interface{}, err error) {
close(intercepted)
Expand Down
4 changes: 2 additions & 2 deletions pkg/grpc/packet/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestGRPCCommunication(t *testing.T) {
case rs = <-serverOut:
assert.Failf(t, "shouldn't have received any packet", "Got: %#v", rs)
default:
//ok!
// ok!
}
}

Expand All @@ -63,7 +63,7 @@ func TestConstructorOptions(t *testing.T) {
WithGRPCServerOptions(grpc.UnaryInterceptor(func(
ctx context.Context,
req interface{},
info *grpc.UnaryServerInfo,
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler,
) (resp interface{}, err error) {
close(intercepted)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ifaces/poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestPoller(t *testing.T) {
// fake net.Interfaces implementation that returns two different sets of
// interfaces on successive invocations
firstInvocation := true
var fakeInterfaces = func(handle netns.NsHandle) ([]Interface, error) {
var fakeInterfaces = func(_ netns.NsHandle) ([]Interface, error) {
if firstInvocation {
firstInvocation = false
return []Interface{{"foo", 1, netns.None()}, {"bar", 2, netns.None()}}, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/ifaces/registerer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func TestRegisterer(t *testing.T) {
watcher := NewWatcher(10)
registry := NewRegisterer(watcher, 10)
// mock net.Interfaces and linkSubscriber to control which interfaces are discovered
watcher.interfaces = func(handle netns.NsHandle) ([]Interface, error) {
watcher.interfaces = func(_ netns.NsHandle) ([]Interface, error) {
return []Interface{{"foo", 1, netns.None()}, {"bar", 2, netns.None()}, {"baz", 3, netns.None()}}, nil
}
inputLinks := make(chan netlink.LinkUpdate, 10)
watcher.linkSubscriberAt = func(nsHandle netns.NsHandle, ch chan<- netlink.LinkUpdate, done <-chan struct{}) error {
watcher.linkSubscriberAt = func(_ netns.NsHandle, ch chan<- netlink.LinkUpdate, _ <-chan struct{}) error {
go func() {
for link := range inputLinks {
ch <- link
Expand Down
2 changes: 1 addition & 1 deletion pkg/ifaces/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (w *Watcher) sendUpdates(ctx context.Context, ns string, out chan Event) {
}()
// subscribe for interface events
links := make(chan netlink.LinkUpdate)
if err = wait.PollUntilContextTimeout(ctx, 50*time.Microsecond, time.Second, true, func(ctx context.Context) (done bool, err error) {
if err = wait.PollUntilContextTimeout(ctx, 50*time.Microsecond, time.Second, true, func(_ context.Context) (done bool, err error) {
if ns == "" {
netnsHandle = netns.None()
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/ifaces/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func TestWatcher(t *testing.T) {

watcher := NewWatcher(10)
// mock net.Interfaces and linkSubscriber to control which interfaces are discovered
watcher.interfaces = func(handle netns.NsHandle) ([]Interface, error) {
watcher.interfaces = func(_ netns.NsHandle) ([]Interface, error) {
return []Interface{{"foo", 1, netns.None()}, {"bar", 2, netns.None()}, {"baz", 3, netns.None()}}, nil
}
inputLinks := make(chan netlink.LinkUpdate, 10)
watcher.linkSubscriberAt = func(ns netns.NsHandle, ch chan<- netlink.LinkUpdate, done <-chan struct{}) error {
watcher.linkSubscriberAt = func(_ netns.NsHandle, ch chan<- netlink.LinkUpdate, _ <-chan struct{}) error {
go func() {
for link := range inputLinks {
ch <- link
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func TestRecordBinaryEncoding(t *testing.T) {
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, // u64 bytes
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, // u64 flow_start_time
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, // u64 flow_end_time
0x13, 0x14, //flags
0x13, 0x14, // flags
0x33, // u8 errno
0x60, // u8 dscp
// pkt_drops structure
0x10, 0x11, 0x12, 0x13, // u32 packets
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, // u64 bytes
0x1c, 0x1d, //flags
0x1c, 0x1d, // flags
0x1e, // state
0x11, 0, 0, 0, //case
0x11, 0, 0, 0, // case
// dns_record structure
01, 00, // id
0x80, 00, // flags
Expand Down

0 comments on commit 8424fa8

Please sign in to comment.