Skip to content

Commit f1057a8

Browse files
committed
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 3793725 commit f1057a8

35 files changed

+86
-69
lines changed

src/go/k8s/.golangci.yml

Lines changed: 2 additions & 1 deletion
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.

src/go/k8s/apis/redpanda/v1alpha1/cluster_types.go

Lines changed: 9 additions & 5 deletions
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() {
@@ -908,12 +909,14 @@ type TLSConfig struct {
908909
// Kafka API
909910

910911
// GetPort returns API port
912+
//
911913
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
912914
func (k KafkaAPI) GetPort() int {
913915
return k.Port
914916
}
915917

916918
// GetTLS returns API TLSConfig
919+
//
917920
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
918921
func (k KafkaAPI) GetTLS() *TLSConfig {
919922
return &TLSConfig{
@@ -925,6 +928,7 @@ func (k KafkaAPI) GetTLS() *TLSConfig {
925928
}
926929

927930
// GetExternal returns API's ExternalConnectivityConfig
931+
//
928932
//nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer
929933
func (k KafkaAPI) GetExternal() *ExternalConnectivityConfig {
930934
return &k.External

src/go/k8s/apis/redpanda/v1alpha1/cluster_types_test.go

Lines changed: 1 addition & 1 deletion
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

src/go/k8s/apis/redpanda/v1alpha1/cluster_webhook_test.go

Lines changed: 8 additions & 8 deletions
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{
@@ -1233,7 +1233,7 @@ func TestExternalKafkaPortSpecified(t *testing.T) {
12331233
func TestKafkaTLSRules(t *testing.T) {
12341234
rpCluster := validRedpandaCluster()
12351235

1236-
// nolint:dupl // the tests are not duplicates
1236+
//nolint:dupl // the tests are not duplicates
12371237
t.Run("different issuer for two tls listeners", func(t *testing.T) {
12381238
newRp := rpCluster.DeepCopy()
12391239
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1256,7 +1256,7 @@ func TestKafkaTLSRules(t *testing.T) {
12561256
assert.Error(t, err)
12571257
})
12581258

1259-
// nolint:dupl // the tests are not duplicates
1259+
//nolint:dupl // the tests are not duplicates
12601260
t.Run("same issuer for two tls listeners is allowed", func(t *testing.T) {
12611261
newRp := rpCluster.DeepCopy()
12621262
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1279,7 +1279,7 @@ func TestKafkaTLSRules(t *testing.T) {
12791279
assert.NoError(t, err)
12801280
})
12811281

1282-
// nolint:dupl // the tests are not duplicates
1282+
//nolint:dupl // the tests are not duplicates
12831283
t.Run("different nodeSecretRef for two tls listeners", func(t *testing.T) {
12841284
newRp := rpCluster.DeepCopy()
12851285
newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{
@@ -1302,7 +1302,7 @@ func TestKafkaTLSRules(t *testing.T) {
13021302
assert.Error(t, err)
13031303
})
13041304

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

src/go/k8s/apis/redpanda/v1alpha1/common_types.go

Lines changed: 1 addition & 1 deletion
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
}

src/go/k8s/apis/redpanda/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
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 (

src/go/k8s/apis/redpanda/v1alpha1/webhook_suite_test.go

Lines changed: 2 additions & 2 deletions
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

src/go/k8s/controllers/redpanda/cluster_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ type ClusterReconciler struct {
7878
//
7979
// For more details, check Reconcile and its Result here:
8080
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
81-
// nolint:funlen // todo break down
81+
//
82+
//nolint:funlen // todo break down
8283
func (r *ClusterReconciler) Reconcile(
8384
ctx context.Context, req ctrl.Request,
8485
) (ctrl.Result, error) {
@@ -295,7 +296,7 @@ func (r *ClusterReconciler) reportStatus(
295296
}
296297

297298
observedNodesInternal := make([]string, 0, len(observedPods.Items))
298-
// nolint:gocritic // the copies are necessary for further redpandacluster updates
299+
//nolint:gocritic // the copies are necessary for further redpandacluster updates
299300
for _, item := range observedPods.Items {
300301
observedNodesInternal = append(observedNodesInternal, fmt.Sprintf("%s.%s", item.Name, internalFQDN))
301302
}
@@ -380,7 +381,7 @@ func (r *ClusterReconciler) WithClusterDomain(
380381
return r
381382
}
382383

383-
// nolint:funlen,gocyclo // External nodes list should be refactored
384+
//nolint:funlen,gocyclo // External nodes list should be refactored
384385
func (r *ClusterReconciler) createExternalNodesList(
385386
ctx context.Context,
386387
pods []corev1.Pod,

src/go/k8s/controllers/redpanda/cluster_controller_configuration.go

Lines changed: 3 additions & 2 deletions
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 {

src/go/k8s/controllers/redpanda/cluster_controller_configuration_drift.go

Lines changed: 2 additions & 1 deletion
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) {

src/go/k8s/controllers/redpanda/console_controller.go

Lines changed: 2 additions & 2 deletions
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))

src/go/k8s/controllers/redpanda/console_controller_test.go

Lines changed: 1 addition & 1 deletion
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

src/go/k8s/controllers/redpanda/suite_test.go

Lines changed: 3 additions & 3 deletions
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 {

src/go/k8s/main.go

Lines changed: 2 additions & 2 deletions
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

src/go/k8s/pkg/admin/admin.go

Lines changed: 4 additions & 2 deletions
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,

src/go/k8s/pkg/console/configmap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ var (
188188
)
189189

190190
func (cm *ConfigMap) genLogin(ctx context.Context) (e EnterpriseLogin, err error) {
191-
if provider := cm.consoleobj.Spec.Login; provider != nil { // nolint:nestif // login config is complex
191+
if provider := cm.consoleobj.Spec.Login; provider != nil { //nolint:nestif // login config is complex
192192
enterpriseLogin := EnterpriseLogin{
193193
Enabled: provider.Enabled,
194194
}
@@ -203,7 +203,7 @@ func (cm *ConfigMap) genLogin(ctx context.Context) (e EnterpriseLogin, err error
203203
}
204204
enterpriseLogin.JWTSecret = string(jwt)
205205

206-
switch { // nolint:gocritic // will support more providers
206+
switch { //nolint:gocritic // will support more providers
207207
case provider.Google != nil:
208208
cc := redpandav1alpha1.SecretKeyRef{
209209
Namespace: provider.Google.ClientCredentialsRef.Namespace,
@@ -282,7 +282,7 @@ var (
282282
// REF https://github.com/redpanda-data/console/blob/master/backend/pkg/schema/client.go#L60
283283
DefaultCaFilePath = "/etc/ssl/certs/ca-certificates.crt"
284284

285-
SchemaRegistryTLSDir = "/redpanda/schema-registry" // nolint:revive // readable enough
285+
SchemaRegistryTLSDir = "/redpanda/schema-registry"
286286
SchemaRegistryTLSCaFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "ca.crt")
287287
SchemaRegistryTLSCertFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "tls.crt")
288288
SchemaRegistryTLSKeyFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "tls.key")
@@ -462,7 +462,7 @@ func (cm *ConfigMap) delete(ctx context.Context, skip string) error {
462462
if err := cm.List(ctx, cms, client.MatchingLabels(labels.ForConsole(cm.consoleobj)), client.InNamespace(cm.consoleobj.GetNamespace())); err != nil {
463463
return err
464464
}
465-
for _, obj := range cms.Items { // nolint:gocritic // more readable, configmap list is few
465+
for _, obj := range cms.Items { //nolint:gocritic // more readable, configmap list is few
466466
if skip != "" && skip == obj.GetName() {
467467
continue
468468
}

src/go/k8s/pkg/console/console.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
)
2222

2323
// ConsoleConfig is the config passed to the Redpanda Console app
24-
type ConsoleConfig struct { // nolint:revive // more readable
24+
type ConsoleConfig struct {
2525
// Grabbed from https://github.com/redpanda-data/console/
2626
// Copying the config types because they don't have Enterprise fields and not all fields are supported yet
2727
MetricsNamespace string `json:"metricsNamespace" yaml:"metricsNamespace"`

src/go/k8s/pkg/console/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (d *Deployment) ensureSyncedSecrets(ctx context.Context) (string, error) {
187187
if d.clusterobj.IsSchemaRegistryMutualTLSEnabled() {
188188
clientCert, exists := d.store.GetSchemaRegistryClientCert(d.clusterobj)
189189
if !exists {
190-
return "", fmt.Errorf("get schema registry client certificate: %s", "not found") // nolint:goerr113 // no need to declare new error type
190+
return "", fmt.Errorf("get schema registry client certificate: %s", "not found") //nolint:goerr113 // no need to declare new error type
191191
}
192192
certfile := getOrEmpty("tls.crt", clientCert.Data)
193193
keyfile := getOrEmpty("tls.key", clientCert.Data)
@@ -200,7 +200,7 @@ func (d *Deployment) ensureSyncedSecrets(ctx context.Context) (string, error) {
200200
if ca.useCaCert() {
201201
caCert, exists := d.store.GetSchemaRegistryNodeCert(d.clusterobj)
202202
if !exists {
203-
return "", fmt.Errorf("get schema registry node certificate: %s", "not found") // nolint:goerr113 // no need to declare new error type
203+
return "", fmt.Errorf("get schema registry node certificate: %s", "not found") //nolint:goerr113 // no need to declare new error type
204204
}
205205
cafile := getOrEmpty("ca.crt", caCert.Data)
206206
data["ca.crt"] = []byte(cafile)

src/go/k8s/pkg/console/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewStore(cl client.Client) *Store {
3636

3737
// Sync synchronizes watched resources to the store
3838
func (s *Store) Sync(cluster *redpandav1alpha1.Cluster) error {
39-
if cluster.IsSchemaRegistryTLSEnabled() { // nolint:nestif // sync is complex
39+
if cluster.IsSchemaRegistryTLSEnabled() { //nolint:nestif // sync is complex
4040
if cluster.IsSchemaRegistryMutualTLSEnabled() {
4141
schemaRegistryClientCert, err := syncSchemaRegistryCert(
4242
s.context,

0 commit comments

Comments
 (0)