Skip to content

Commit d8ffbf4

Browse files
committed
fix linter errors
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 3be49bd commit d8ffbf4

9 files changed

+42
-27
lines changed

api/v1beta1/azurecluster_webhook.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ func (c *AzureCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
4444
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azurecluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclusters,versions=v1beta1,name=validation.azurecluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4545
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-azurecluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclusters,versions=v1beta1,name=default.azurecluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4646

47+
// AzureClusterWebhook implements validating and mutating webhook for AzureCluster.
4748
type AzureClusterWebhook struct{}
4849

4950
var _ webhook.CustomValidator = &AzureClusterWebhook{}
5051
var _ webhook.CustomDefaulter = &AzureClusterWebhook{}
5152

5253
// Default implements webhook.CustomDefaulter so a webhook will be registered for the type.
53-
func (_ *AzureClusterWebhook) Default(_ context.Context, obj runtime.Object) error {
54+
func (*AzureClusterWebhook) Default(_ context.Context, obj runtime.Object) error {
5455
c, ok := obj.(*AzureCluster)
5556
if !ok {
5657
return fmt.Errorf("expected an AzureCluster object but got %T", c)
@@ -61,7 +62,7 @@ func (_ *AzureClusterWebhook) Default(_ context.Context, obj runtime.Object) err
6162
}
6263

6364
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
64-
func (_ *AzureClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
65+
func (*AzureClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
6566
c, ok := obj.(*AzureCluster)
6667
if !ok {
6768
return nil, fmt.Errorf("expected an AzureCluster object but got %T", c)
@@ -71,7 +72,7 @@ func (_ *AzureClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Obje
7172
}
7273

7374
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
74-
func (_ *AzureClusterWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
75+
func (*AzureClusterWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
7576
c, ok := newObj.(*AzureCluster)
7677
if !ok {
7778
return nil, fmt.Errorf("expected an AzureCluster object but got %T", c)
@@ -219,6 +220,6 @@ func (c *AzureCluster) validateSubnetUpdate(old *AzureCluster) field.ErrorList {
219220
}
220221

221222
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
222-
func (_ *AzureClusterWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
223+
func (*AzureClusterWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
223224
return nil, nil
224225
}

api/v1beta1/azureclusteridentity_webhook.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1beta1
1919
import (
2020
"context"
2121
"fmt"
22+
2223
apierrors "k8s.io/apimachinery/pkg/api/errors"
2324
"k8s.io/apimachinery/pkg/runtime"
2425
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -45,7 +46,7 @@ type azureClusterIdentityWebhook struct{}
4546
var _ webhook.CustomValidator = &azureClusterIdentityWebhook{}
4647

4748
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
48-
func (_ *azureClusterIdentityWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
49+
func (*azureClusterIdentityWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
4950
c, ok := obj.(*AzureClusterIdentity)
5051
if !ok {
5152
return nil, fmt.Errorf("expected an AzureClusterIdentity object but got %T", c)
@@ -55,7 +56,7 @@ func (_ *azureClusterIdentityWebhook) ValidateCreate(_ context.Context, obj runt
5556
}
5657

5758
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
58-
func (_ *azureClusterIdentityWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
59+
func (*azureClusterIdentityWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
5960
c, ok := newObj.(*AzureClusterIdentity)
6061
if !ok {
6162
return nil, fmt.Errorf("expected an AzureClusterIdentity object but got %T", c)
@@ -76,6 +77,6 @@ func (_ *azureClusterIdentityWebhook) ValidateUpdate(_ context.Context, oldRaw,
7677
}
7778

7879
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
79-
func (_ *azureClusterIdentityWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
80+
func (*azureClusterIdentityWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
8081
return nil, nil
8182
}

api/v1beta1/azureclustertemplate_webhook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type azureClusterTemplateWebhook struct{}
5050
var _ webhook.CustomDefaulter = &azureClusterTemplateWebhook{}
5151

5252
// Default implements webhook.CustomDefaulter so a webhook will be registered for the type.
53-
func (_ *azureClusterTemplateWebhook) Default(_ context.Context, obj runtime.Object) error {
53+
func (*azureClusterTemplateWebhook) Default(_ context.Context, obj runtime.Object) error {
5454
c, ok := obj.(*AzureClusterTemplate)
5555
if !ok {
5656
return fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
@@ -63,7 +63,7 @@ func (_ *azureClusterTemplateWebhook) Default(_ context.Context, obj runtime.Obj
6363
var _ webhook.CustomValidator = &azureClusterTemplateWebhook{}
6464

6565
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
66-
func (_ *azureClusterTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
66+
func (*azureClusterTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
6767
c, ok := obj.(*AzureClusterTemplate)
6868
if !ok {
6969
return nil, fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
@@ -73,7 +73,7 @@ func (_ *azureClusterTemplateWebhook) ValidateCreate(_ context.Context, obj runt
7373
}
7474

7575
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
76-
func (_ *azureClusterTemplateWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
76+
func (*azureClusterTemplateWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
7777
c, ok := newObj.(*AzureClusterTemplate)
7878
if !ok {
7979
return nil, fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
@@ -94,6 +94,6 @@ func (_ *azureClusterTemplateWebhook) ValidateUpdate(_ context.Context, oldRaw,
9494
}
9595

9696
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
97-
func (_ *azureClusterTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
97+
func (*azureClusterTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
9898
return nil, nil
9999
}

api/v1beta1/azuremachinetemplate_webhook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var _ webhook.CustomDefaulter = &azureMachineTemplateWebhook{}
5757
var _ webhook.CustomValidator = &azureMachineTemplateWebhook{}
5858

5959
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
60-
func (_ *azureMachineTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
60+
func (*azureMachineTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
6161
r := obj.(*AzureMachineTemplate)
6262
spec := r.Spec.Template.Spec
6363

@@ -145,12 +145,12 @@ func (r *azureMachineTemplateWebhook) ValidateUpdate(ctx context.Context, oldRaw
145145
}
146146

147147
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
148-
func (_ *azureMachineTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
148+
func (*azureMachineTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
149149
return nil, nil
150150
}
151151

152152
// Default implements webhookutil.defaulter so a webhook will be registered for the type.
153-
func (_ *azureMachineTemplateWebhook) Default(_ context.Context, obj runtime.Object) error {
153+
func (*azureMachineTemplateWebhook) Default(_ context.Context, obj runtime.Object) error {
154154
t := obj.(*AzureMachineTemplate)
155155
if err := t.Spec.Template.Spec.SetDefaultSSHPublicKey(); err != nil {
156156
ctrl.Log.WithName("SetDefault").Error(err, "SetDefaultSSHPublicKey failed")

api/v1beta1/azuremanagedcluster_webhook.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
import (
2020
"context"
21+
2122
"k8s.io/apimachinery/pkg/runtime"
2223
ctrl "sigs.k8s.io/controller-runtime"
2324
"sigs.k8s.io/controller-runtime/pkg/webhook"

api/v1beta1/azuremanagedclustertemplate_webhook.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
import (
2020
"context"
21+
2122
"k8s.io/apimachinery/pkg/runtime"
2223
ctrl "sigs.k8s.io/controller-runtime"
2324
"sigs.k8s.io/controller-runtime/pkg/webhook"

azure/scope/cluster_test.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ func TestNewClusterScope(t *testing.T) {
103103
},
104104
},
105105
}
106-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
106+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
107+
g.Expect(err).NotTo(HaveOccurred())
107108

108109
fakeIdentity := &infrav1.AzureClusterIdentity{
109110
Spec: infrav1.AzureClusterIdentitySpec{
@@ -117,7 +118,7 @@ func TestNewClusterScope(t *testing.T) {
117118
initObjects := []runtime.Object{cluster, azureCluster, fakeIdentity, fakeSecret}
118119
fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build()
119120

120-
_, err := NewClusterScope(context.TODO(), ClusterScopeParams{
121+
_, err = NewClusterScope(context.TODO(), ClusterScopeParams{
121122
Cluster: cluster,
122123
AzureCluster: azureCluster,
123124
Client: fakeClient,
@@ -230,7 +231,8 @@ func TestAPIServerHost(t *testing.T) {
230231
tc.azureCluster.ObjectMeta = metav1.ObjectMeta{
231232
Name: cluster.Name,
232233
}
233-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), &tc.azureCluster)
234+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), &tc.azureCluster)
235+
g.Expect(err).NotTo(HaveOccurred())
234236

235237
clusterScope := &ClusterScope{
236238
Cluster: cluster,
@@ -388,7 +390,8 @@ func TestGettingSecurityRules(t *testing.T) {
388390
t.Run(tt.name, func(t *testing.T) {
389391
g := NewWithT(t)
390392

391-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), tt.azureCluster)
393+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), tt.azureCluster)
394+
g.Expect(err).NotTo(HaveOccurred())
392395

393396
clusterScope := &ClusterScope{
394397
Cluster: tt.cluster,
@@ -2276,7 +2279,8 @@ func TestOutboundLBName(t *testing.T) {
22762279
azureCluster.Spec.NetworkSpec.NodeOutboundLB = tc.nodeOutboundLB
22772280
}
22782281

2279-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2282+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2283+
g.Expect(err).NotTo(HaveOccurred())
22802284

22812285
clusterScope := &ClusterScope{
22822286
AzureCluster: azureCluster,
@@ -2390,7 +2394,8 @@ func TestBackendPoolName(t *testing.T) {
23902394
},
23912395
}
23922396

2393-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2397+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2398+
g.Expect(err).NotTo(HaveOccurred())
23942399

23952400
if tc.customAPIServerBackendPoolName != "" {
23962401
azureCluster.Spec.NetworkSpec.APIServerLB.BackendPool.Name = tc.customAPIServerBackendPoolName
@@ -2503,7 +2508,8 @@ func TestOutboundPoolName(t *testing.T) {
25032508
}
25042509
}
25052510

2506-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2511+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
2512+
g.Expect(err).NotTo(HaveOccurred())
25072513

25082514
clusterScope := &ClusterScope{
25092515
AzureCluster: azureCluster,

controllers/helpers_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ func TestGetCloudProviderConfig(t *testing.T) {
102102
cluster := newCluster("foo")
103103
azureCluster := newAzureCluster("bar")
104104

105-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
105+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
106+
g.Expect(err).NotTo(HaveOccurred())
107+
106108
azureClusterCustomVnet := newAzureClusterWithCustomVnet("bar")
107-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureClusterCustomVnet)
109+
err = (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureClusterCustomVnet)
110+
g.Expect(err).NotTo(HaveOccurred())
108111

109112
cases := map[string]struct {
110113
cluster *clusterv1.Cluster
@@ -302,7 +305,8 @@ func TestReconcileAzureSecret(t *testing.T) {
302305
cluster := newCluster("foo")
303306
azureCluster := newAzureCluster("bar")
304307

305-
(&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
308+
err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)
309+
g.Expect(err).NotTo(HaveOccurred())
306310
cluster.Name = "testCluster"
307311

308312
fakeIdentity := &infrav1.AzureClusterIdentity{

exp/api/v1beta1/azuremachinepoolmachine_webhook.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1beta1
1919
import (
2020
"context"
2121
"fmt"
22+
2223
"github.com/pkg/errors"
2324
"k8s.io/apimachinery/pkg/runtime"
2425
ctrl "sigs.k8s.io/controller-runtime"
@@ -40,12 +41,12 @@ type azureMachinePoolMachineWebhook struct{}
4041
var _ webhook.CustomValidator = &azureMachinePoolMachineWebhook{}
4142

4243
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
43-
func (_ *azureMachinePoolMachineWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
44+
func (*azureMachinePoolMachineWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
4445
return nil, nil
4546
}
4647

4748
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
48-
func (_ *azureMachinePoolMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
49+
func (*azureMachinePoolMachineWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
4950
ampm, ok := newObj.(*AzureMachinePoolMachine)
5051
if !ok {
5152
return nil, fmt.Errorf("expected an AzureMachinePoolMachine object but got %T", ampm)
@@ -64,6 +65,6 @@ func (_ *azureMachinePoolMachineWebhook) ValidateUpdate(ctx context.Context, old
6465
}
6566

6667
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
67-
func (_ *azureMachinePoolMachineWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
68+
func (*azureMachinePoolMachineWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
6869
return nil, nil
6970
}

0 commit comments

Comments
 (0)