Skip to content

Commit

Permalink
Merge pull request #2728 from adityabhatia/bump-golangci-lint-1.56.1
Browse files Browse the repository at this point in the history
🌱  bump golangci-lint to v1.56.1
  • Loading branch information
k8s-ci-robot authored Feb 9, 2024
2 parents 74d6c06 + b638ee7 commit 0b59c31
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # tag=v3.7.0
with:
version: v1.55.2
version: v1.56.1
args: --out-format=colored-line-number
working-directory: ${{matrix.working-directory}}
8 changes: 4 additions & 4 deletions controllers/clustermodule_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ func (r Reconciler) PopulateWatchesOnController(mgr manager.Manager, controller
source.Kind(mgr.GetCache(), &controlplanev1.KubeadmControlPlane{}),
handler.EnqueueRequestsFromMapFunc(r.toAffinityInput),
predicate.Funcs{
GenericFunc: func(genericEvent event.GenericEvent) bool {
GenericFunc: func(event.GenericEvent) bool {
return false
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
UpdateFunc: func(event.UpdateEvent) bool {
return false
},
},
Expand All @@ -236,10 +236,10 @@ func (r Reconciler) PopulateWatchesOnController(mgr manager.Manager, controller
source.Kind(mgr.GetCache(), &clusterv1.MachineDeployment{}),
handler.EnqueueRequestsFromMapFunc(r.toAffinityInput),
predicate.Funcs{
GenericFunc: func(genericEvent event.GenericEvent) bool {
GenericFunc: func(event.GenericEvent) bool {
return false
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
UpdateFunc: func(event.UpdateEvent) bool {
return false
},
},
Expand Down
8 changes: 4 additions & 4 deletions controllers/clustermodule_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func TestReconciler_Reconcile(t *testing.T) {
},
{
name: "when machine deployment is being deleted",
beforeFn: func(object client.Object) {
beforeFn: func(client.Object) {
tym := metav1.NewTime(time.Now())
md.ObjectMeta.DeletionTimestamp = &tym
md.ObjectMeta.Finalizers = append(md.ObjectMeta.Finalizers, "keep-this-for-the-test")
Expand All @@ -335,7 +335,7 @@ func TestReconciler_Reconcile(t *testing.T) {
},
{
name: "when machine deployment is being deleted & cluster module info is set in object",
beforeFn: func(object client.Object) {
beforeFn: func(client.Object) {
tym := metav1.NewTime(time.Now())
md.ObjectMeta.DeletionTimestamp = &tym
md.ObjectMeta.Finalizers = append(md.ObjectMeta.Finalizers, "keep-this-for-the-test")
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestReconciler_Reconcile(t *testing.T) {
},
{
name: "when control plane & machine deployment are being deleted & cluster module info is set in object",
beforeFn: func(object client.Object) {
beforeFn: func(client.Object) {
tym := metav1.NewTime(time.Now())
kcp.ObjectMeta.DeletionTimestamp = &tym
kcp.ObjectMeta.Finalizers = append(kcp.ObjectMeta.Finalizers, "keep-this-for-the-test")
Expand All @@ -392,7 +392,7 @@ func TestReconciler_Reconcile(t *testing.T) {
},
{
name: "when control plane & machine deployment are being deleted & cluster module info is not set",
beforeFn: func(object client.Object) {
beforeFn: func(client.Object) {
tym := metav1.NewTime(time.Now())
kcp.ObjectMeta.DeletionTimestamp = &tym
kcp.ObjectMeta.Finalizers = append(kcp.ObjectMeta.Finalizers, "keep-this-for-the-test")
Expand Down
2 changes: 1 addition & 1 deletion controllers/vspheremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func AddMachineControllerToManager(ctx context.Context, controllerManagerContext
ctrlbldr.WithPredicates(predicate.Funcs{
// ignore creation events since this controller is responsible for
// the creation of the type.
CreateFunc: func(e event.CreateEvent) bool {
CreateFunc: func(event.CreateEvent) bool {
return false
},
}),
Expand Down
6 changes: 3 additions & 3 deletions controllers/vspherevm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ func AddVMControllerToManager(ctx context.Context, controllerManagerCtx *capvcon
newCluster := e.ObjectNew.(*infrav1.VSphereCluster)
return !clustermodule.Compare(oldCluster.Spec.ClusterModules, newCluster.Spec.ClusterModules)
},
CreateFunc: func(e event.CreateEvent) bool { return false },
DeleteFunc: func(e event.DeleteEvent) bool { return false },
GenericFunc: func(e event.GenericEvent) bool { return false },
CreateFunc: func(event.CreateEvent) bool { return false },
DeleteFunc: func(event.DeleteEvent) bool { return false },
GenericFunc: func(event.GenericEvent) bool { return false },
}),
).
Watches(
Expand Down
2 changes: 1 addition & 1 deletion internal/test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func NewTestEnvironment(ctx context.Context) *TestEnvironment {
Username: simr.Username(),
Password: simr.Password(),
}
managerOpts.AddToManager = func(ctx context.Context, controllerCtx *capvcontext.ControllerManagerContext, mgr ctrlmgr.Manager) error {
managerOpts.AddToManager = func(_ context.Context, _ *capvcontext.ControllerManagerContext, mgr ctrlmgr.Manager) error {
if err := (&webhooks.VSphereClusterTemplateWebhook{}).SetupWebhookWithManager(mgr); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/webhooks/vspheredeploymentzone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestVSphereDeploymentZone_Default(t *testing.T) {
for _, tt := range tests {
// Need to reinit the test variable
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(*testing.T) {
vdz := infrav1.VSphereDeploymentZone{
Spec: infrav1.VSphereDeploymentZoneSpec{
ControlPlane: tt.boolPtr,
Expand Down
2 changes: 1 addition & 1 deletion internal/webhooks/vspherefailuredomain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestVSphereFailureDomain_ValidateCreate(t *testing.T) {
for _, tt := range tests {
// Need to reinit the test variable
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(*testing.T) {
webhook := &VSphereFailureDomainWebhook{}
_, err := webhook.ValidateCreate(context.Background(), &tt.failureDomain)
if tt.errExpected == nil || !*tt.errExpected {
Expand Down
4 changes: 2 additions & 2 deletions internal/webhooks/vspheremachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestVSphereMachine_ValidateCreate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereMachineWebhook{}
_, err := webhook.ValidateCreate(context.Background(), tc.vsphereMachine)
if tc.wantErr {
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestVSphereMachine_ValidateUpdate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereMachineWebhook{}
_, err := webhook.ValidateUpdate(context.Background(), tc.oldVSphereMachine, tc.vsphereMachine)
if tc.wantErr {
Expand Down
4 changes: 2 additions & 2 deletions internal/webhooks/vspheremachinetemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestVSphereMachineTemplate_ValidateCreate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereMachineTemplateWebhook{}
_, err := webhook.ValidateCreate(context.Background(), tc.vsphereMachine)
if tc.wantErr {
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestVSphereMachineTemplate_ValidateUpdate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereMachineTemplateWebhook{}
ctx := context.Background()
if tc.req != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/webhooks/vspherevm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestVSphereVM_ValidateCreate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereVMWebhook{}
_, err := webhook.ValidateCreate(context.Background(), tc.vSphereVM)
if tc.wantErr {
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestVSphereVM_ValidateUpdate(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
webhook := &VSphereVMWebhook{}
_, err := webhook.ValidateUpdate(context.Background(), tc.oldVSphereVM, tc.vSphereVM)
if tc.wantErr {
Expand Down
2 changes: 1 addition & 1 deletion packaging/flavorgen/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func RootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "flavorgen",
Short: "flavorgen generates clusterctl templates for Cluster API Provider vSphere",
RunE: func(command *cobra.Command, args []string) error {
RunE: func(command *cobra.Command, _ []string) error {
return RunRoot(command)
},
SilenceUsage: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func parseGcfgTag(field reflect.StructField) (string, bool, bool) {
lenTagParts := len(tagParts)
if lenTagParts > 0 {
tagName := tagParts[0]
if len(tagName) > 0 && tagName != "-" {
if tagName != "" && tagName != "-" {
name = tagName
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ folder = "kubernetes"

for _, tc := range testcases {
tc := tc
t.Run(tc.testName, func(t *testing.T) {
t.Run(tc.testName, func(*testing.T) {
buf, err := tc.configObj.MarshalINI()
if err != nil {
if tc.expectedError == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/identity/identity_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
Expect(k8sclient.Create(ctx, ns)).NotTo(HaveOccurred())

return nil
}, func(data []byte) {})
}, func([]byte) {})

var _ = SynchronizedAfterSuite(func() {}, func() {
if err := env.Stop(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (o *Options) defaults() {
if ns, ok := os.LookupEnv("POD_NAMESPACE"); ok {
o.PodNamespace = ns
} else if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
if ns := strings.TrimSpace(string(data)); len(ns) > 0 {
if ns := strings.TrimSpace(string(data)); ns != "" {
o.PodNamespace = ns
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ password: '%s'
t.Fatal(err)
}

t.Run(test.name, func(t *testing.T) {
t.Run(test.name, func(*testing.T) {
o := &Options{
// needs an object ref to be present
KubeConfig: &rest.Config{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/govmomi/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func Test_ShouldRetryTask(t *testing.T) {
}
})

t.Run("for task in error state", func(t *testing.T) {
t.Run("for task in error state", func(*testing.T) {
task := baseTask(types.TaskInfoStateError, "task is stuck")

reconciled, err := checkAndRetryTask(ctx, vmCtx, &task)
Expand Down
2 changes: 1 addition & 1 deletion pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (s *Session) GetVersion() (infrav1.VCenterVersion, error) {

// Clear is meant to destroy all the cached sessions.
func Clear() {
sessionCache.Range(func(key, s any) bool {
sessionCache.Range(func(_, s any) bool {
cachedSession := s.(*Session)
_ = cachedSession.Logout(context.Background())
return true
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ func TestConvertProviderIDToUUID(t *testing.T) {
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
actualUUID := util.ConvertProviderIDToUUID(tc.providerID)
g.Expect(actualUUID).To(gomega.Equal(tc.expectedUUID))
})
Expand Down Expand Up @@ -1001,7 +1001,7 @@ func TestConvertUUIDtoProviderID(t *testing.T) {
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
actualProviderID := util.ConvertUUIDToProviderID(tc.uuid)
g.Expect(actualProviderID).To(gomega.Equal(tc.expectedProviderID))
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestSetControllerReferenceWithOverride(t *testing.T) {

for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
controllerManagerContext := fake.NewControllerManagerContext(tc.controlled)
actualErr := SetControllerReferenceWithOverride(tc.newOwner, tc.controlled, controllerManagerContext.Scheme)
if tc.expectErr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

t.Run("fails if unknown kind", func(t *testing.T) {
t.Run("fails if unknown kind", func(*testing.T) {
// TODO implement test case
})

Expand Down Expand Up @@ -226,7 +226,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

t.Run("fails if unknown kind", func(t *testing.T) {
t.Run("fails if unknown kind", func(*testing.T) {
// TODO implement test case
})

Expand Down Expand Up @@ -298,7 +298,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

t.Run("fails if unknown kind", func(t *testing.T) {
t.Run("fails if unknown kind", func(*testing.T) {
// TODO implement test case
})

Expand Down Expand Up @@ -364,7 +364,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

t.Run("fails if unknown kind", func(t *testing.T) {
t.Run("fails if unknown kind", func(*testing.T) {
// TODO implement test case
})

Expand Down Expand Up @@ -583,7 +583,7 @@ func Test_cache_client(t *testing.T) {
g.Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

t.Run("fails if unknown kind", func(t *testing.T) {
t.Run("fails if unknown kind", func(*testing.T) {
// TODO implement test case
})

Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/tmp-to-be-deleted/runtime/cache/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *cache) startGarbageCollector(ctx context.Context) error {
wg.Wait()
}()

if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(ctx context.Context) (done bool, err error) {
if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(context.Context) (done bool, err error) {
if atomic.LoadInt64(&workers) < int64(c.garbageCollectorConcurrency) {
return false, nil
}
Expand Down
4 changes: 2 additions & 2 deletions test/infrastructure/tmp-to-be-deleted/runtime/cache/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *cache) startSyncer(ctx context.Context) error {
wg.Wait()
}()

if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(ctx context.Context) (done bool, err error) {
if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(context.Context) (done bool, err error) {
if !syncLoopStarted {
return false, nil
}
Expand All @@ -90,7 +90,7 @@ func (c *cache) startSyncer(ctx context.Context) error {
return fmt.Errorf("failed to start sync loop: %v", err)
}

if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(ctx context.Context) (done bool, err error) {
if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, false, func(context.Context) (done bool, err error) {
if atomic.LoadInt64(&workers) < int64(c.syncConcurrency) {
return false, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (h *apiServerHandler) apiV1PortForward(req *restful.Request, resp *restful.
streamChan,
podName,
podNamespace,
func(ctx context.Context, podName, podNamespace, _ string, stream io.ReadWriteCloser) error {
func(ctx context.Context, _, _, _ string, stream io.ReadWriteCloser) error {
// Given that in the in-memory provider there is no real infrastructure, and thus no real workload cluster,
// we are going to forward all the connection back to the same server (the CAPIM controller pod).
return h.doPortForward(ctx, req.Request.Host, stream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
// HTTPStreamReceived is the httpstream.NewStreamHandler for port
// forward streams. Each valid stream is sent to the streams channel.
func HTTPStreamReceived(streamsCh chan httpstream.Stream) func(httpstream.Stream, <-chan struct{}) error {
return func(stream httpstream.Stream, replySent <-chan struct{}) error {
return func(stream httpstream.Stream, _ <-chan struct{}) error {
// make sure it has a valid stream type header
streamType := stream.Headers().Get(corev1.StreamType)
if streamType == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Test_etcd_scalingflow(t *testing.T) {
g := NewWithT(t)
ctx := metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{":authority": "etcd-1"}))
manager := inmemoryruntime.NewManager(scheme)
resourceGroupResolver := func(host string) (string, error) { return "group1", nil }
resourceGroupResolver := func(string) (string, error) { return "group1", nil }
c := &clusterServerServer{
baseServer: &baseServer{
log: log.FromContext(ctx),
Expand Down Expand Up @@ -99,7 +99,7 @@ func Test_etcd_scalingflow(t *testing.T) {
var etcdMemberToRemove uint64 = 2
var etcdMemberToBeLeader uint64 = 3

t.Run("move leader and remove etcd member", func(t *testing.T) {
t.Run("move leader and remove etcd member", func(*testing.T) {
_, err := m.MoveLeader(ctx, &pb.MoveLeaderRequest{TargetID: etcdMemberToBeLeader})
g.Expect(err).NotTo(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/tmp-to-be-deleted/server/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (m *WorkloadClustersMux) AddAPIServer(wclName, podName string, caCert *x509

// Wait until the sever is working.
var pollErr error
err = wait.PollUntilContextTimeout(context.TODO(), 10*time.Millisecond, 1*time.Second, true, func(ctx context.Context) (done bool, err error) {
err = wait.PollUntilContextTimeout(context.TODO(), 10*time.Millisecond, 1*time.Second, true, func(context.Context) (done bool, err error) {
d := &net.Dialer{Timeout: 50 * time.Millisecond}
conn, err := tls.DialWithDialer(d, "tcp", wcl.HostPort(), &tls.Config{
InsecureSkipVerify: true, //nolint:gosec // config is used to connect to our own port.
Expand Down

0 comments on commit 0b59c31

Please sign in to comment.