diff --git a/.golangci.yml b/.golangci.yml index 7f24d327800..4fd4550a05d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,15 +16,14 @@ linters: - godot - gofmt - goimports - - golint - gosec - gosimple - govet - ineffassign - - interfacer - misspell - nakedret - prealloc + - revive - staticcheck - structcheck - unconvert diff --git a/azure/services/managedclusters/managedclusters.go b/azure/services/managedclusters/managedclusters.go index eb0a70d8271..43919ab2957 100644 --- a/azure/services/managedclusters/managedclusters.go +++ b/azure/services/managedclusters/managedclusters.go @@ -36,8 +36,8 @@ import ( ) var ( - defaultUser string = "azureuser" - managedIdentity string = "msi" + defaultUser = "azureuser" + managedIdentity = "msi" ) // ManagedClusterScope defines the scope interface for a managed cluster. diff --git a/exp/controllers/helpers.go b/exp/controllers/helpers.go index ab2c3d5eca9..d41352a05ab 100644 --- a/exp/controllers/helpers.go +++ b/exp/controllers/helpers.go @@ -477,7 +477,7 @@ func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Lo // AzureClusterToAzureMachinePoolsFunc is a handler.MapFunc to be used to enqueue // requests for reconciliation of AzureMachinePools. -func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, kClient client.Client, log logr.Logger) handler.MapFunc { +func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, cli client.Client, log logr.Logger) handler.MapFunc { return func(o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -489,7 +489,7 @@ func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, kClient client.Cli } logWithValues := log.WithValues("AzureCluster", c.Name, "Namespace", c.Namespace) - cluster, err := util.GetOwnerCluster(ctx, kClient, c.ObjectMeta) + cluster, err := util.GetOwnerCluster(ctx, cli, c.ObjectMeta) switch { case apierrors.IsNotFound(err) || cluster == nil: logWithValues.V(4).Info("owning cluster not found") @@ -501,7 +501,7 @@ func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, kClient client.Cli labels := map[string]string{clusterv1.ClusterLabelName: cluster.Name} ampl := &infrav1exp.AzureMachinePoolList{} - if err := kClient.List(ctx, ampl, client.InNamespace(c.Namespace), client.MatchingLabels(labels)); err != nil { + if err := cli.List(ctx, ampl, client.InNamespace(c.Namespace), client.MatchingLabels(labels)); err != nil { logWithValues.Error(err, "failed to list AzureMachinePools") return nil } @@ -522,7 +522,7 @@ func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, kClient client.Cli // AzureMachinePoolToAzureMachinePoolMachines maps an AzureMachinePool to its child AzureMachinePoolMachines through // Cluster and MachinePool labels. -func AzureMachinePoolToAzureMachinePoolMachines(ctx context.Context, kClient client.Client, log logr.Logger) handler.MapFunc { +func AzureMachinePoolToAzureMachinePoolMachines(ctx context.Context, cli client.Client, log logr.Logger) handler.MapFunc { return func(o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -539,7 +539,7 @@ func AzureMachinePoolToAzureMachinePoolMachines(ctx context.Context, kClient cli infrav1exp.MachinePoolNameLabel: amp.Name, } ampml := &infrav1exp.AzureMachinePoolMachineList{} - if err := kClient.List(ctx, ampml, client.InNamespace(amp.Namespace), client.MatchingLabels(labels)); err != nil { + if err := cli.List(ctx, ampml, client.InNamespace(amp.Namespace), client.MatchingLabels(labels)); err != nil { logWithValues.Error(err, "failed to list AzureMachinePoolMachines") return nil } diff --git a/exp/controllers/helpers_test.go b/exp/controllers/helpers_test.go index a3606ece965..19b717d973f 100644 --- a/exp/controllers/helpers_test.go +++ b/exp/controllers/helpers_test.go @@ -566,10 +566,10 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { Setup: func(g *GomegaWithT, t *testing.T) (*mock_log.MockLogger, *gomock.Controller, client.Client) { mockCtrl := gomock.NewController(t) log := mock_log.NewMockLogger(mockCtrl) - kClient := fake.NewClientBuilder().WithScheme(newScheme(g)).Build() + cli := fake.NewClientBuilder().WithScheme(newScheme(g)).Build() log.EXPECT().Error(gomockinternal.ErrStrEq("expected a AzureCluster but got a *v1beta1.MachinePool"), "failed to get AzureCluster") - return log, mockCtrl, kClient + return log, mockCtrl, cli }, Expect: func(g *GomegaWithT, reqs []reconcile.Request) { g.Expect(reqs).To(HaveLen(0)) @@ -583,11 +583,11 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { Setup: func(g *GomegaWithT, t *testing.T) (*mock_log.MockLogger, *gomock.Controller, client.Client) { mockCtrl := gomock.NewController(t) log := mock_log.NewMockLogger(mockCtrl) - kClient := fake.NewClientBuilder().WithScheme(newScheme(g)).Build() + cli := fake.NewClientBuilder().WithScheme(newScheme(g)).Build() log.EXPECT().WithValues("AzureCluster", "azurefoo", "Namespace", "default").Return(log) log.EXPECT().V(4).Return(log) log.EXPECT().Info("owning cluster not found") - return log, mockCtrl, kClient + return log, mockCtrl, cli }, Expect: func(g *GomegaWithT, reqs []reconcile.Request) { g.Expect(reqs).To(HaveLen(0)) @@ -607,9 +607,9 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { newCluster(clusterName), newAzureCluster(clusterName), } - kClient := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() + cli := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() log.EXPECT().WithValues("AzureCluster", "azurefoo", "Namespace", "default").Return(logWithValues) - return log, mockCtrl, kClient + return log, mockCtrl, cli }, Expect: func(g *GomegaWithT, reqs []reconcile.Request) { g.Expect(reqs).To(HaveLen(0)) @@ -631,9 +631,9 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { newMachinePool(clusterName, "pool1"), newMachinePool(clusterName, "pool2"), } - kClient := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() + cli := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() log.EXPECT().WithValues("AzureCluster", "azurefoo", "Namespace", "default").Return(logWithValues) - return log, mockCtrl, kClient + return log, mockCtrl, cli }, Expect: func(g *GomegaWithT, reqs []reconcile.Request) { g.Expect(reqs).To(HaveLen(0)) @@ -656,9 +656,9 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { newAzureMachinePool(clusterName, "azurepool2"), newMachinePoolWithInfrastructureRef(clusterName, "pool2"), } - kClient := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() + cli := fake.NewClientBuilder().WithScheme(newScheme(g)).WithRuntimeObjects(initObj...).Build() log.EXPECT().WithValues("AzureCluster", "azurefoo", "Namespace", "default").Return(logWithValues) - return log, mockCtrl, kClient + return log, mockCtrl, cli }, Expect: func(g *GomegaWithT, reqs []reconcile.Request) { g.Expect(reqs).To(HaveLen(1)) @@ -677,10 +677,10 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { t.Run(c.Name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) - log, mockctrl, kClient := c.Setup(g, t) + log, mockctrl, cli := c.Setup(g, t) defer mockctrl.Finish() - f := AzureClusterToAzureMachinePoolsFunc(context.Background(), kClient, log) + f := AzureClusterToAzureMachinePoolsFunc(context.Background(), cli, log) reqs := f(c.MapObjectFactory(g)) c.Expect(g, reqs) })