Skip to content

Commit 1b5b6f6

Browse files
committed
operator: k8s: bump golangci-lint to latest version
There was a change for nolint directives: golangci/golangci-lint#3109 (comment) And we are adding confidence of 0.8 in revive to avoid false positives.
1 parent b0c1cbf commit 1b5b6f6

37 files changed

+92
-75
lines changed

.golangci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ linters-settings:
2626
misspell:
2727
locale: US
2828
nolintlint:
29-
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
3029
allow-unused: false # report any unused nolint directives
3130
require-explanation: false # don't require an explanation for nolint directives
3231
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
32+
revive:
33+
confidence: 0.8
3334

3435
linters:
3536
# please, do not use `enable-all`: it's deprecated and will be removed soon.

apis/redpanda/v1alpha1/cluster_types.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ type RedpandaResourceRequirements struct {
5050
// * Is limited by 2Gi per core if requests.memory is set.
5151
//
5252
// Example:
53-
// in: minimum requirement per core, 2GB
54-
// in: Requests.Memory, 16GB
55-
// => maxAllowedCores = 8
56-
// if requestedCores == 8, set smp = 8 (with 2GB per core)
57-
// if requestedCores == 4, set smp = 4 (with 4GB per core)
53+
//
54+
// in: minimum requirement per core, 2GB
55+
// in: Requests.Memory, 16GB
56+
// => maxAllowedCores = 8
57+
// if requestedCores == 8, set smp = 8 (with 2GB per core)
58+
// if requestedCores == 4, set smp = 4 (with 4GB per core)
5859
func (r *RedpandaResourceRequirements) RedpandaCPU() *resource.Quantity {
5960
q := r.Redpanda.Cpu()
6061
if q == nil || q.IsZero() {
@@ -924,12 +925,14 @@ type TLSConfig struct {
924925
// Kafka API
925926

926927
// GetPort returns API port
928+
//
927929
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
928930
func (k KafkaAPI) GetPort() int {
929931
return k.Port
930932
}
931933

932934
// GetTLS returns API TLSConfig
935+
//
933936
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
934937
func (k KafkaAPI) GetTLS() *TLSConfig {
935938
return &TLSConfig{
@@ -941,6 +944,7 @@ func (k KafkaAPI) GetTLS() *TLSConfig {
941944
}
942945

943946
// GetExternal returns API's ExternalConnectivityConfig
947+
//
944948
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
945949
func (k KafkaAPI) GetExternal() *ExternalConnectivityConfig {
946950
return &k.External

apis/redpanda/v1alpha1/cluster_types_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"k8s.io/utils/pointer"
2222
)
2323

24-
// nolint:funlen // this is ok for a test
24+
//nolint:funlen // this is ok for a test
2525
func TestRedpandaResourceRequirements(t *testing.T) {
2626
type test struct {
2727
name string

apis/redpanda/v1alpha1/cluster_webhook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func (r *Cluster) validateKafkaListeners() field.ErrorList {
366366
r.Spec.Configuration.KafkaAPI,
367367
"bootstrap port cannot be empty"))
368368
}
369-
// nolint:dupl // not identical
369+
//nolint:dupl // not identical
370370
if external != nil && external.External.EndpointTemplate != "" {
371371
if external.External.Subdomain == "" {
372372
allErrs = append(allErrs,
@@ -395,7 +395,7 @@ func checkValidEndpointTemplate(tmpl string) error {
395395
return err
396396
}
397397

398-
// nolint:funlen,gocyclo // it's a sequence of checks
398+
//nolint:funlen,gocyclo // it's a sequence of checks
399399
func (r *Cluster) validatePandaproxyListeners() field.ErrorList {
400400
var allErrs field.ErrorList
401401
var proxyExternal *PandaproxyAPI
@@ -447,7 +447,7 @@ func (r *Cluster) validatePandaproxyListeners() field.ErrorList {
447447
r.Spec.Configuration.PandaproxyAPI[i],
448448
"sudomain of external pandaproxy must be the same as kafka's"))
449449
}
450-
// nolint:dupl // not identical
450+
//nolint:dupl // not identical
451451
if kafkaExternal != nil && proxyExternal.External.EndpointTemplate != "" {
452452
if proxyExternal.External.Subdomain == "" {
453453
allErrs = append(allErrs,

apis/redpanda/v1alpha1/cluster_webhook_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"k8s.io/utils/pointer"
2828
)
2929

30-
// nolint:funlen // this is ok for a test
30+
//nolint:funlen // this is ok for a test
3131
func TestDefault(t *testing.T) {
3232
type test struct {
3333
name string
@@ -780,7 +780,7 @@ func TestCreation(t *testing.T) {
780780
assert.Error(t, err)
781781
})
782782

783-
// nolint:dupl // the values are different
783+
//nolint:dupl // the values are different
784784
t.Run("incorrect redpanda memory (need <= limit)", func(t *testing.T) {
785785
memory := redpandaCluster.DeepCopy()
786786
memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{
@@ -804,7 +804,7 @@ func TestCreation(t *testing.T) {
804804
assert.Error(t, err)
805805
})
806806

807-
// nolint:dupl // the values are different
807+
//nolint:dupl // the values are different
808808
t.Run("correct redpanda memory", func(t *testing.T) {
809809
memory := redpandaCluster.DeepCopy()
810810
memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{
@@ -828,7 +828,7 @@ func TestCreation(t *testing.T) {
828828
assert.NoError(t, err)
829829
})
830830

831-
// nolint:dupl // the values are different
831+
//nolint:dupl // the values are different
832832
t.Run("correct redpanda memory (boundary check)", func(t *testing.T) {
833833
memory := redpandaCluster.DeepCopy()
834834
memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{
@@ -1038,7 +1038,7 @@ func TestCreation(t *testing.T) {
10381038
err := rp.ValidateCreate()
10391039
assert.Error(t, err)
10401040
})
1041-
// nolint:dupl // not really a duplicate
1041+
//nolint:dupl // not really a duplicate
10421042
t.Run("endpoint template not allowed for adminapi", func(t *testing.T) {
10431043
rp := redpandaCluster.DeepCopy()
10441044
const commonDomain = "company.org"
@@ -1100,7 +1100,7 @@ func TestCreation(t *testing.T) {
11001100
err := rp.ValidateCreate()
11011101
assert.NoError(t, err)
11021102
})
1103-
// nolint:dupl // not really a duplicate
1103+
//nolint:dupl // not really a duplicate
11041104
t.Run("invalid endpoint template in pandaproxy API", func(t *testing.T) {
11051105
rp := redpandaCluster.DeepCopy()
11061106

@@ -1117,7 +1117,7 @@ func TestCreation(t *testing.T) {
11171117
err := rp.ValidateCreate()
11181118
assert.Error(t, err)
11191119
})
1120-
// nolint:dupl // not really a duplicate
1120+
//nolint:dupl // not really a duplicate
11211121
t.Run("valid endpoint template in pandaproxy API", func(t *testing.T) {
11221122
rp := redpandaCluster.DeepCopy()
11231123

@@ -1345,7 +1345,7 @@ func TestExternalKafkaPortSpecified(t *testing.T) {
13451345
func TestKafkaTLSRules(t *testing.T) {
13461346
rpCluster := validRedpandaCluster()
13471347

1348-
// nolint:dupl // the tests are not duplicates
1348+
//nolint:dupl // the tests are not duplicates
13491349
t.Run("different issuer for two tls listeners", func(t *testing.T) {
13501350
newRp := rpCluster.DeepCopy()
13511351
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1368,7 +1368,7 @@ func TestKafkaTLSRules(t *testing.T) {
13681368
assert.Error(t, err)
13691369
})
13701370

1371-
// nolint:dupl // the tests are not duplicates
1371+
//nolint:dupl // the tests are not duplicates
13721372
t.Run("same issuer for two tls listeners is allowed", func(t *testing.T) {
13731373
newRp := rpCluster.DeepCopy()
13741374
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1391,7 +1391,7 @@ func TestKafkaTLSRules(t *testing.T) {
13911391
assert.NoError(t, err)
13921392
})
13931393

1394-
// nolint:dupl // the tests are not duplicates
1394+
//nolint:dupl // the tests are not duplicates
13951395
t.Run("different nodeSecretRef for two tls listeners", func(t *testing.T) {
13961396
newRp := rpCluster.DeepCopy()
13971397
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1414,7 +1414,7 @@ func TestKafkaTLSRules(t *testing.T) {
14141414
assert.Error(t, err)
14151415
})
14161416

1417-
// nolint:dupl // the tests are not duplicates
1417+
//nolint:dupl // the tests are not duplicates
14181418
t.Run("same nodesecretref for two tls listeners is allowed", func(t *testing.T) {
14191419
newRp := rpCluster.DeepCopy()
14201420
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{

apis/redpanda/v1alpha1/common_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (s *SecretKeyRef) GetValue(secret *corev1.Secret, defaultKey string) ([]byt
4242

4343
value, ok := secret.Data[key]
4444
if !ok {
45-
return nil, fmt.Errorf("getting value from Secret %s/%s: key %s not found", s.Namespace, s.Name, key) // nolint:goerr113 // no need to declare new error type
45+
return nil, fmt.Errorf("getting value from Secret %s/%s: key %s not found", s.Namespace, s.Name, key) //nolint:goerr113 // no need to declare new error type
4646
}
4747
return value, nil
4848
}

apis/redpanda/v1alpha1/groupversion_info.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// by the Apache License, Version 2.0
99

1010
// Package v1alpha1 contains API Schema definitions for the redpanda v1alpha1 API group
11-
//+kubebuilder:object:generate=true
12-
//+groupName=redpanda.vectorized.io
11+
// +kubebuilder:object:generate=true
12+
// +groupName=redpanda.vectorized.io
1313
package v1alpha1
1414

1515
import (

apis/redpanda/v1alpha1/webhook_suite_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
. "github.com/onsi/ginkgo"
2222
. "github.com/onsi/gomega"
2323
redpandav1alpha1 "github.com/redpanda-data/redpanda/src/go/k8s/apis/redpanda/v1alpha1"
24-
admissionv1beta1 "k8s.io/api/admission/v1beta1" // nolint:goimports // crlfmt
24+
admissionv1beta1 "k8s.io/api/admission/v1beta1" //nolint:goimports // crlfmt
2525
//+kubebuilder:scaffold:imports
2626
"k8s.io/apimachinery/pkg/runtime"
2727
ctrl "sigs.k8s.io/controller-runtime"
@@ -108,7 +108,7 @@ var _ = BeforeSuite(func() {
108108
dialer := &net.Dialer{Timeout: time.Second}
109109
addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
110110
Eventually(func() error {
111-
// nolint:gosec // the tests can have insecure verify flag set to true
111+
//nolint:gosec // the tests can have insecure verify flag set to true
112112
conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
113113
if err != nil {
114114
return err

cmd/configurator/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func getExternalIP(node *corev1.Node) string {
297297
return ""
298298
}
299299

300-
// nolint:funlen // envs are many
300+
//nolint:funlen // envs are many
301301
func checkEnvVars() (configuratorConfig, error) {
302302
var result error
303303
var extCon string

controllers/redpanda/cluster_controller.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ type ClusterReconciler struct {
8080
//
8181
// For more details, check Reconcile and its Result here:
8282
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
83-
// nolint:funlen // todo break down
83+
//
84+
//nolint:funlen // todo break down
8485
func (r *ClusterReconciler) Reconcile(
8586
ctx context.Context, req ctrl.Request,
8687
) (ctrl.Result, error) {
@@ -297,7 +298,7 @@ func (r *ClusterReconciler) reportStatus(
297298
}
298299

299300
observedNodesInternal := make([]string, 0, len(observedPods.Items))
300-
// nolint:gocritic // the copies are necessary for further redpandacluster updates
301+
//nolint:gocritic // the copies are necessary for further redpandacluster updates
301302
for _, item := range observedPods.Items {
302303
observedNodesInternal = append(observedNodesInternal, fmt.Sprintf("%s.%s", item.Name, internalFQDN))
303304
}
@@ -382,7 +383,7 @@ func (r *ClusterReconciler) WithClusterDomain(
382383
return r
383384
}
384385

385-
// nolint:funlen,gocyclo // External nodes list should be refactored
386+
//nolint:funlen,gocyclo // External nodes list should be refactored
386387
func (r *ClusterReconciler) createExternalNodesList(
387388
ctx context.Context,
388389
pods []corev1.Pod,

controllers/redpanda/cluster_controller_configuration.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828
)
2929

3030
// reconcileConfiguration ensures that the cluster configuration is synchronized with expected data
31-
// nolint:funlen // splitting makes it difficult to follow
31+
//
32+
//nolint:funlen // splitting makes it difficult to follow
3233
func (r *ClusterReconciler) reconcileConfiguration(
3334
ctx context.Context,
3435
redpandaCluster *redpandav1alpha1.Cluster,
@@ -345,7 +346,7 @@ func (r *ClusterReconciler) synchronizeStatusWithCluster(
345346
return redpandaCluster.Status.GetCondition(conditionData.Type), nil
346347
}
347348

348-
// nolint:gocritic // I like this if else chain
349+
//nolint:gocritic // I like this if else chain
349350
func mapStatusToCondition(
350351
clusterStatus admin.ConfigStatusResponse,
351352
) redpandav1alpha1.ClusterCondition {

controllers/redpanda/cluster_controller_configuration_drift.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ type ClusterConfigurationDriftReconciler struct {
4848
}
4949

5050
// Reconcile detects drift in configuration for clusters and schedules a patch.
51-
// nolint:funlen // May be broken down
51+
//
52+
//nolint:funlen // May be broken down
5253
func (r *ClusterConfigurationDriftReconciler) Reconcile(
5354
ctx context.Context, req ctrl.Request,
5455
) (ctrl.Result, error) {

controllers/redpanda/console_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *ConsoleReconciler) Reconcile(
7474
}
7575
// Checks if Console is valid to be created in specified namespace
7676
if !console.IsAllowedNamespace() {
77-
err := fmt.Errorf("invalid Console namespace") // nolint:goerr113 // no need to declare new error type
77+
err := fmt.Errorf("invalid Console namespace") //nolint:goerr113 // no need to declare new error type
7878
log.Error(err, "Console must be created in Redpanda namespace. Set --allow-console-any-ns=true to enable")
7979
return ctrl.Result{}, err
8080
}
@@ -159,7 +159,7 @@ func (r *Reconciling) Do(
159159
resources.NewIngress(r.Client, console, r.Scheme, subdomain, console.GetName(), consolepkg.ServicePortName, log).WithTLS(resources.LEClusterIssuer, fmt.Sprintf("%s-redpanda", cluster.GetName())),
160160
}
161161
for _, each := range applyResources {
162-
if err := each.Ensure(ctx); err != nil { // nolint:gocritic // more readable
162+
if err := each.Ensure(ctx); err != nil { //nolint:gocritic // more readable
163163
var ra *resources.RequeueAfterError
164164
if errors.As(err, &ra) {
165165
log.V(debugLogLevel).Info(fmt.Sprintf("Requeue ensuring resource after %d: %s", ra.RequeueAfter, ra.Msg))

controllers/redpanda/console_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ var _ = Describe("Console controller", func() {
268268

269269
var (
270270
googleName = fmt.Sprintf("%s-google", ConsoleName)
271-
googleClientId = "123456654321-abcdefghi123456abcdefghi123456ab.apps.googleusercontent.com" // nolint:stylecheck,revive // Console uses clientId naming
271+
googleClientId = "123456654321-abcdefghi123456abcdefghi123456ab.apps.googleusercontent.com" //nolint:stylecheck // Console uses clientId naming
272272
googleClientSecret = "some-random-client-secret"
273273
)
274274

controllers/redpanda/suite_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (m *mockAdminAPI) GetFeatures(
355355
}, nil
356356
}
357357

358-
// nolint:gocritic // It's test API
358+
//nolint:gocritic // It's test API
359359
func (m *mockAdminAPI) RegisterPropertySchema(
360360
name string, metadata admin.ConfigPropertyMetadata,
361361
) {
@@ -422,7 +422,7 @@ func (m *mockAdminAPI) GetNodeConfig(
422422
return admin.NodeConfig{}, nil
423423
}
424424

425-
// nolint:goerr113 // test code
425+
//nolint:goerr113 // test code
426426
func (s *scopedMockAdminAPI) GetNodeConfig(
427427
ctx context.Context,
428428
) (admin.NodeConfig, error) {
@@ -508,7 +508,7 @@ func (m *mockAdminAPI) DisableMaintenanceMode(_ context.Context, _ int) error {
508508
return nil
509509
}
510510

511-
// nolint:goerr113 // test code
511+
//nolint:goerr113 // test code
512512
func (m *mockAdminAPI) SetBrokerStatus(
513513
id int, status admin.MembershipStatus,
514514
) error {

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ var (
4040
setupLog = ctrl.Log.WithName("setup")
4141
)
4242

43-
// nolint:wsl // the init was generated by kubebuilder
43+
//nolint:wsl // the init was generated by kubebuilder
4444
func init() {
4545
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
4646
utilruntime.Must(redpandav1alpha1.AddToScheme(scheme))
4747
utilruntime.Must(cmapiv1.AddToScheme(scheme))
4848
//+kubebuilder:scaffold:scheme
4949
}
5050

51-
// nolint:funlen // length looks good
51+
//nolint:funlen // length looks good
5252
func main() {
5353
var (
5454
clusterDomain string

pkg/admin/admin.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func NewInternalAdminAPI(
7575
}
7676

7777
// AdminAPIClient is a sub interface of the admin API containing what we need in the operator
78-
// nolint:revive // usually package is called adminutils
78+
//
79+
7980
type AdminAPIClient interface {
8081
Config(ctx context.Context) (admin.Config, error)
8182
ClusterConfigStatus(ctx context.Context, sendToLeader bool) (admin.ConfigStatusResponse, error)
@@ -99,7 +100,8 @@ type AdminAPIClient interface {
99100
var _ AdminAPIClient = &admin.AdminAPI{}
100101

101102
// AdminAPIClientFactory is an abstract constructor of admin API clients
102-
// nolint:revive // usually package is called adminutils
103+
//
104+
103105
type AdminAPIClientFactory func(
104106
ctx context.Context,
105107
k8sClient client.Reader,

0 commit comments

Comments
 (0)