Skip to content

Commit 1ea6dbb

Browse files
committed
fix linting
1 parent 5c279e6 commit 1ea6dbb

14 files changed

+23
-23
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
- name: golangci-lint
2424
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
2525
with:
26-
version: v1.58
26+
version: v1.61

.golangci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ linters:
1414
- errcheck
1515
- errchkjson
1616
- errname
17-
- exportloopref
17+
- copyloopvar
1818
- fatcontext
1919
- ginkgolinter
2020
- gocheckcompilerdirectives
@@ -148,6 +148,12 @@ issues:
148148
- linters:
149149
- gosec
150150
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
151+
- linters:
152+
- gosec
153+
text: "G115: integer overflow conversion int -> int32"
154+
- linters:
155+
- govet
156+
text: "printf: non-constant format string in call to sigs.k8s.io/cluster-api/util/conditions.MarkFalse"
151157
- linters:
152158
- revive
153159
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"

api/v1beta1/gcpcluster_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ func TestGCPCluster_ValidateUpdate(t *testing.T) {
8787
},
8888
}
8989
for _, test := range tests {
90-
test := test
9190
t.Run(test.name, func(t *testing.T) {
9291
t.Parallel()
9392
warn, err := test.newCluster.ValidateUpdate(test.oldCluster)

api/v1beta1/gcpclustertemplate_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ func TestGCPClusterTemplate_ValidateUpdate(t *testing.T) {
8181
},
8282
}
8383
for _, test := range tests {
84-
test := test
8584
t.Run(test.name, func(t *testing.T) {
8685
t.Parallel()
8786
warn, err := test.newTemplate.ValidateUpdate(test.oldTemplate)

api/v1beta1/gcpmachine_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func TestGCPMachine_ValidateCreate(t *testing.T) {
167167
},
168168
}
169169
for _, test := range tests {
170-
test := test
171170
t.Run(test.name, func(t *testing.T) {
172171
t.Parallel()
173172
warn, err := test.GCPMachine.ValidateCreate()

api/v1beta1/gcpmachinetemplate_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func TestGCPMachineTemplate_ValidateCreate(t *testing.T) {
107107
},
108108
}
109109
for _, test := range tests {
110-
test := test
111110
t.Run(test.name, func(t *testing.T) {
112111
t.Parallel()
113112
warn, err := test.template.ValidateCreate()

cloud/scope/managedcontrolplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (s *ManagedControlPlaneScope) GetCredential() *Credential {
180180

181181
// GetAllNodePools gets all node pools for the control plane.
182182
func (s *ManagedControlPlaneScope) GetAllNodePools(ctx context.Context) ([]infrav1exp.GCPManagedMachinePool, []clusterv1exp.MachinePool, error) {
183-
if s.AllManagedMachinePools == nil || len(s.AllManagedMachinePools) == 0 {
183+
if len(s.AllManagedMachinePools) == 0 {
184184
listOptions := []client.ListOption{
185185
client.InNamespace(s.GCPManagedControlPlane.Namespace),
186186
client.MatchingLabels(map[string]string{clusterv1.ClusterNameLabel: s.Cluster.Name}),

cloud/scope/managedmachinepool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func ConvertToSdkNodePool(nodePool infrav1exp.GCPManagedMachinePool, machinePool
237237
sdkNodePool.Config.DiskType = string(*nodePool.Spec.DiskType)
238238
}
239239
if nodePool.Spec.DiskSizeGB != nil {
240-
sdkNodePool.Config.DiskSizeGb = int32(*nodePool.Spec.DiskSizeGB)
240+
sdkNodePool.Config.DiskSizeGb = int32(*nodePool.Spec.DiskSizeGB) //nolint:gosec
241241
}
242242
if len(nodePool.Spec.NodeNetwork.Tags) != 0 {
243243
sdkNodePool.Config.Tags = nodePool.Spec.NodeNetwork.Tags

controllers/suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ func init() {
5050
func TestAPIs(t *testing.T) {
5151
RegisterFailHandler(Fail)
5252
// fetch the current config
53-
suiteConfig, reporterConfig := GinkgoConfiguration()
53+
_, reporterConfig := GinkgoConfiguration()
5454
// adjust it
55-
suiteConfig.FailFast = true
5655
reporterConfig.FullTrace = true
5756
RunSpecs(t, "Controller Suite", reporterConfig)
5857
}

exp/api/v1beta1/gcpmanagedmachinepool_webhook.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,31 @@ func (r *GCPManagedMachinePool) validateScaling() field.ErrorList {
8989
maxField := field.NewPath("spec", "scaling", "maxCount")
9090
locationPolicyField := field.NewPath("spec", "scaling", "locationPolicy")
9191

92-
min := r.Spec.Scaling.MinCount
93-
max := r.Spec.Scaling.MaxCount
92+
minCount := r.Spec.Scaling.MinCount
93+
maxCount := r.Spec.Scaling.MaxCount
9494
locationPolicy := r.Spec.Scaling.LocationPolicy
9595

9696
// cannot specify autoscaling config if autoscaling is disabled
9797
if r.Spec.Scaling.EnableAutoscaling != nil && !*r.Spec.Scaling.EnableAutoscaling {
98-
if min != nil {
98+
if minCount != nil {
9999
allErrs = append(allErrs, field.Forbidden(minField, "minCount cannot be specified when autoscaling is disabled"))
100100
}
101-
if max != nil {
101+
if maxCount != nil {
102102
allErrs = append(allErrs, field.Forbidden(maxField, "maxCount cannot be specified when autoscaling is disabled"))
103103
}
104104
if locationPolicy != nil {
105105
allErrs = append(allErrs, field.Forbidden(locationPolicyField, "locationPolicy cannot be specified when autoscaling is disabled"))
106106
}
107107
}
108108

109-
if min != nil {
109+
if minCount != nil {
110110
// validates min >= 0
111-
if *min < 0 {
112-
allErrs = append(allErrs, field.Invalid(minField, *min, "must be greater or equal zero"))
111+
if *minCount < 0 {
112+
allErrs = append(allErrs, field.Invalid(minField, *minCount, "must be greater or equal zero"))
113113
}
114114
// validates min <= max
115-
if max != nil && *max < *min {
116-
allErrs = append(allErrs, field.Invalid(maxField, *max, "must be greater than field "+minField.String()))
115+
if maxCount != nil && *maxCount < *minCount {
116+
allErrs = append(allErrs, field.Invalid(maxField, *maxCount, "must be greater than field "+minField.String()))
117117
}
118118
}
119119
}

0 commit comments

Comments
 (0)