Skip to content

Commit c24b91e

Browse files
committed
Make linters happy
Following a rebase against the latest state of `main`, a few errors had popped up.
1 parent 0a1c149 commit c24b91e

6 files changed

Lines changed: 17 additions & 21 deletions

File tree

e2e/multi-cluster/offline_cluster_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package multicluster_test
22

33
import (
44
"encoding/json"
5-
"fmt"
65
"time"
76

87
. "github.com/onsi/ginkgo/v2"
@@ -79,8 +78,8 @@ var _ = Describe("Offline cluster detection", func() {
7978
Eventually(func(g Gomega) {
8079
out, err := k.Get(
8180
"bundledeployments", "-A",
82-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-name=%s", name),
83-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-namespace=%s", env.ClusterRegistrationNamespace),
81+
"-l", "fleet.cattle.io/bundle-name="+name,
82+
"-l", "fleet.cattle.io/bundle-namespace="+env.ClusterRegistrationNamespace,
8483
"-o", `jsonpath={.items[0].status.conditions}`,
8584
)
8685
g.Expect(err).ToNot(HaveOccurred(), out)
@@ -108,8 +107,8 @@ var _ = Describe("Offline cluster detection", func() {
108107
Eventually(func(g Gomega) {
109108
out, err := k.Get(
110109
"bundledeployments", "-A",
111-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-name=%s", name),
112-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-namespace=%s", env.ClusterRegistrationNamespace),
110+
"-l", "fleet.cattle.io/bundle-name="+name,
111+
"-l", "fleet.cattle.io/bundle-namespace="+env.ClusterRegistrationNamespace,
113112
"-o", `jsonpath={.items[0].status.conditions}`,
114113
)
115114
g.Expect(err).ToNot(HaveOccurred(), out)
@@ -137,8 +136,8 @@ var _ = Describe("Offline cluster detection", func() {
137136
Eventually(func(g Gomega) {
138137
out, err := k.Get(
139138
"bundledeployments", "-A",
140-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-name=%s", name),
141-
"-l", fmt.Sprintf("fleet.cattle.io/bundle-namespace=%s", env.ClusterRegistrationNamespace),
139+
"-l", "fleet.cattle.io/bundle-name="+name,
140+
"-l", "fleet.cattle.io/bundle-namespace="+env.ClusterRegistrationNamespace,
142141
"-o", `jsonpath={.items[0].status.conditions}`,
143142
)
144143
g.Expect(err).ToNot(HaveOccurred(), out)

internal/cmd/agent/deployer/monitor/condition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ func (c Cond) IsFalse(obj any) bool {
4545
return getStatus(obj, string(c)) == "False"
4646
}
4747

48-
func (c Cond) Unknown(obj interface{}) {
48+
func (c Cond) Unknown(obj any) {
4949
setStatus(obj, string(c), "Unknown")
5050
}
5151

52-
func (c Cond) IsUnknown(obj interface{}) bool {
52+
func (c Cond) IsUnknown(obj any) bool {
5353
return getStatus(obj, string(c)) == "Unknown"
5454
}
5555

internal/cmd/controller/agentmanagement/controllers/cluster/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (i *importHandler) importCluster(cluster *fleet.Cluster, status fleet.Clust
320320
)
321321

322322
if cfg.AgentCheckinInterval.Seconds() == 0 {
323-
return status, fmt.Errorf("agent check-in interval cannot be 0")
323+
return status, errors.New("agent check-in interval cannot be 0")
324324
}
325325

326326
if apiServerURL == "" {

internal/cmd/controller/agentmanagement/controllers/manageagent/manageagent_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package manageagent
22

33
import (
4-
"os"
54
"reflect"
65
"strings"
76
"testing"
@@ -27,9 +26,9 @@ func TestNewAgentBundle(t *testing.T) {
2726
config.Set(&config.Config{AgentCheckinInterval: metav1.Duration{Duration: 0 * time.Second}})
2827

2928
// ensure leader election env is set so NewLeaderElectionOptionsWithPrefix doesn't error
30-
os.Setenv("FLEET_AGENT_ELECTION_LEASE_DURATION", "15s")
31-
os.Setenv("FLEET_AGENT_ELECTION_RENEW_DEADLINE", "10s")
32-
os.Setenv("FLEET_AGENT_ELECTION_RETRY_PERIOD", "2s")
29+
t.Setenv("FLEET_AGENT_ELECTION_LEASE_DURATION", "15s")
30+
t.Setenv("FLEET_AGENT_ELECTION_RENEW_DEADLINE", "10s")
31+
t.Setenv("FLEET_AGENT_ELECTION_RETRY_PERIOD", "2s")
3332

3433
h := handler{systemNamespace: "blah"}
3534
obj, err := h.newAgentBundle("foo", &fleet.Cluster{Spec: fleet.ClusterSpec{AgentNamespace: "bar"}})

internal/cmd/controller/clustermonitor/monitor_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,7 @@ func Test_Run(t *testing.T) {
414414
t.Run(tc.name, func(t *testing.T) {
415415
ctrl := gomock.NewController(t)
416416
testClient := mocks.NewMockK8sClient(ctrl)
417-
ctx, cancel := context.WithCancel(context.Background())
418-
419-
defer cancel()
417+
ctx := t.Context()
420418

421419
testClient.EXPECT().List(ctx, gomock.Any(), gomock.Any()).DoAndReturn(
422420
func(ctx context.Context, list *v1alpha1.ClusterList, opts ...client.ListOption) error {
@@ -469,7 +467,7 @@ func Test_Run(t *testing.T) {
469467
testClient.EXPECT().Status().Return(srw)
470468

471469
srw.EXPECT().Patch(gomock.Any(), gomock.Any(), gomock.Any()).Do(
472-
func(ctx context.Context, bd *v1alpha1.BundleDeployment, p client.Patch, opts ...interface{}) {
470+
func(ctx context.Context, bd *v1alpha1.BundleDeployment, p client.Patch, opts ...any) {
473471
var foundReady, foundMonitored bool
474472
for _, c := range bd.Status.Conditions {
475473
switch c.Type {

internal/config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ type Config struct {
152152
AgentWorkers AgentWorkers `json:"agentWorkers,omitzero"`
153153

154154
// ClusterMonitor represents configuration for the cluster monitor, including its enabled or disabled state.
155-
ClusterMonitor ClusterMonitor `json:"clusterMonitor,omitempty"`
155+
ClusterMonitor ClusterMonitor `json:"clusterMonitor,omitzero"`
156156
}
157157

158158
type AgentWorkers struct {
@@ -179,13 +179,13 @@ type ClusterMonitor struct {
179179
Enabled bool `json:"enabled,omitempty"`
180180

181181
// Interval determines how often the cluster monitor will check for offline downstream clusters.
182-
Interval metav1.Duration `json:"interval,omitempty"`
182+
Interval metav1.Duration `json:"interval,omitzero"`
183183

184184
// Threshold determines how long must have elapsed since a downstream cluster's Fleet agent last reported its
185185
// status to the management cluster, before that downstream cluster is considered offline. If this configured value
186186
// is shorter than three times the agent check-in interval, then that check-in interval-based value will be used
187187
// instead to prevent false positives.
188-
Threshold metav1.Duration `json:"threshold.omitempty"`
188+
Threshold metav1.Duration `json:"threshold,omitzero"`
189189
}
190190

191191
// OnChange is used by agentmanagement to react to config changes. The callback is triggered by 'Set' via

0 commit comments

Comments
 (0)