diff --git a/.golangci.yml b/.golangci.yml index f657eb354c5f..78f2723fc39e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,10 +26,11 @@ linters-settings: misspell: locale: US nolintlint: - allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) allow-unused: false # report any unused nolint directives require-explanation: false # don't require an explanation for nolint directives require-specific: false # don't require nolint directives to be specific about which linter is being skipped + revive: + confidence: 0.8 linters: # please, do not use `enable-all`: it's deprecated and will be removed soon. diff --git a/apis/redpanda/v1alpha1/cluster_types.go b/apis/redpanda/v1alpha1/cluster_types.go index c70668357c14..b7eb17988936 100644 --- a/apis/redpanda/v1alpha1/cluster_types.go +++ b/apis/redpanda/v1alpha1/cluster_types.go @@ -50,11 +50,12 @@ type RedpandaResourceRequirements struct { // * Is limited by 2Gi per core if requests.memory is set. // // Example: -// in: minimum requirement per core, 2GB -// in: Requests.Memory, 16GB -// => maxAllowedCores = 8 -// if requestedCores == 8, set smp = 8 (with 2GB per core) -// if requestedCores == 4, set smp = 4 (with 4GB per core) +// +// in: minimum requirement per core, 2GB +// in: Requests.Memory, 16GB +// => maxAllowedCores = 8 +// if requestedCores == 8, set smp = 8 (with 2GB per core) +// if requestedCores == 4, set smp = 4 (with 4GB per core) func (r *RedpandaResourceRequirements) RedpandaCPU() *resource.Quantity { q := r.Redpanda.Cpu() if q == nil || q.IsZero() { @@ -924,12 +925,14 @@ type TLSConfig struct { // Kafka API // GetPort returns API port +// //nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer func (k KafkaAPI) GetPort() int { return k.Port } // GetTLS returns API TLSConfig +// //nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer func (k KafkaAPI) GetTLS() *TLSConfig { return &TLSConfig{ @@ -941,6 +944,7 @@ func (k KafkaAPI) GetTLS() *TLSConfig { } // GetExternal returns API's ExternalConnectivityConfig +// //nolint:gocritic // TODO KafkaAPI is now 81 bytes, consider a pointer func (k KafkaAPI) GetExternal() *ExternalConnectivityConfig { return &k.External diff --git a/apis/redpanda/v1alpha1/cluster_types_test.go b/apis/redpanda/v1alpha1/cluster_types_test.go index e4a8e2fe3c1a..3140464cdbe6 100644 --- a/apis/redpanda/v1alpha1/cluster_types_test.go +++ b/apis/redpanda/v1alpha1/cluster_types_test.go @@ -21,7 +21,7 @@ import ( "k8s.io/utils/pointer" ) -// nolint:funlen // this is ok for a test +//nolint:funlen // this is ok for a test func TestRedpandaResourceRequirements(t *testing.T) { type test struct { name string diff --git a/apis/redpanda/v1alpha1/cluster_webhook.go b/apis/redpanda/v1alpha1/cluster_webhook.go index 262413d75662..b857157bdab1 100644 --- a/apis/redpanda/v1alpha1/cluster_webhook.go +++ b/apis/redpanda/v1alpha1/cluster_webhook.go @@ -366,7 +366,7 @@ func (r *Cluster) validateKafkaListeners() field.ErrorList { r.Spec.Configuration.KafkaAPI, "bootstrap port cannot be empty")) } - // nolint:dupl // not identical + //nolint:dupl // not identical if external != nil && external.External.EndpointTemplate != "" { if external.External.Subdomain == "" { allErrs = append(allErrs, @@ -395,7 +395,7 @@ func checkValidEndpointTemplate(tmpl string) error { return err } -// nolint:funlen,gocyclo // it's a sequence of checks +//nolint:funlen,gocyclo // it's a sequence of checks func (r *Cluster) validatePandaproxyListeners() field.ErrorList { var allErrs field.ErrorList var proxyExternal *PandaproxyAPI @@ -447,7 +447,7 @@ func (r *Cluster) validatePandaproxyListeners() field.ErrorList { r.Spec.Configuration.PandaproxyAPI[i], "sudomain of external pandaproxy must be the same as kafka's")) } - // nolint:dupl // not identical + //nolint:dupl // not identical if kafkaExternal != nil && proxyExternal.External.EndpointTemplate != "" { if proxyExternal.External.Subdomain == "" { allErrs = append(allErrs, diff --git a/apis/redpanda/v1alpha1/cluster_webhook_test.go b/apis/redpanda/v1alpha1/cluster_webhook_test.go index d636c3e03997..02e13028ef42 100644 --- a/apis/redpanda/v1alpha1/cluster_webhook_test.go +++ b/apis/redpanda/v1alpha1/cluster_webhook_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/pointer" ) -// nolint:funlen // this is ok for a test +//nolint:funlen // this is ok for a test func TestDefault(t *testing.T) { type test struct { name string @@ -780,7 +780,7 @@ func TestCreation(t *testing.T) { assert.Error(t, err) }) - // nolint:dupl // the values are different + //nolint:dupl // the values are different t.Run("incorrect redpanda memory (need <= limit)", func(t *testing.T) { memory := redpandaCluster.DeepCopy() memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{ @@ -804,7 +804,7 @@ func TestCreation(t *testing.T) { assert.Error(t, err) }) - // nolint:dupl // the values are different + //nolint:dupl // the values are different t.Run("correct redpanda memory", func(t *testing.T) { memory := redpandaCluster.DeepCopy() memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{ @@ -828,7 +828,7 @@ func TestCreation(t *testing.T) { assert.NoError(t, err) }) - // nolint:dupl // the values are different + //nolint:dupl // the values are different t.Run("correct redpanda memory (boundary check)", func(t *testing.T) { memory := redpandaCluster.DeepCopy() memory.Spec.Resources = v1alpha1.RedpandaResourceRequirements{ @@ -1038,7 +1038,7 @@ func TestCreation(t *testing.T) { err := rp.ValidateCreate() assert.Error(t, err) }) - // nolint:dupl // not really a duplicate + //nolint:dupl // not really a duplicate t.Run("endpoint template not allowed for adminapi", func(t *testing.T) { rp := redpandaCluster.DeepCopy() const commonDomain = "company.org" @@ -1100,7 +1100,7 @@ func TestCreation(t *testing.T) { err := rp.ValidateCreate() assert.NoError(t, err) }) - // nolint:dupl // not really a duplicate + //nolint:dupl // not really a duplicate t.Run("invalid endpoint template in pandaproxy API", func(t *testing.T) { rp := redpandaCluster.DeepCopy() @@ -1117,7 +1117,7 @@ func TestCreation(t *testing.T) { err := rp.ValidateCreate() assert.Error(t, err) }) - // nolint:dupl // not really a duplicate + //nolint:dupl // not really a duplicate t.Run("valid endpoint template in pandaproxy API", func(t *testing.T) { rp := redpandaCluster.DeepCopy() @@ -1345,7 +1345,7 @@ func TestExternalKafkaPortSpecified(t *testing.T) { func TestKafkaTLSRules(t *testing.T) { rpCluster := validRedpandaCluster() - // nolint:dupl // the tests are not duplicates + //nolint:dupl // the tests are not duplicates t.Run("different issuer for two tls listeners", func(t *testing.T) { newRp := rpCluster.DeepCopy() newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{ @@ -1368,7 +1368,7 @@ func TestKafkaTLSRules(t *testing.T) { assert.Error(t, err) }) - // nolint:dupl // the tests are not duplicates + //nolint:dupl // the tests are not duplicates t.Run("same issuer for two tls listeners is allowed", func(t *testing.T) { newRp := rpCluster.DeepCopy() newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{ @@ -1391,7 +1391,7 @@ func TestKafkaTLSRules(t *testing.T) { assert.NoError(t, err) }) - // nolint:dupl // the tests are not duplicates + //nolint:dupl // the tests are not duplicates t.Run("different nodeSecretRef for two tls listeners", func(t *testing.T) { newRp := rpCluster.DeepCopy() newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{ @@ -1414,7 +1414,7 @@ func TestKafkaTLSRules(t *testing.T) { assert.Error(t, err) }) - // nolint:dupl // the tests are not duplicates + //nolint:dupl // the tests are not duplicates t.Run("same nodesecretref for two tls listeners is allowed", func(t *testing.T) { newRp := rpCluster.DeepCopy() newRp.Spec.Configuration.KafkaAPI[0].TLS = v1alpha1.KafkaAPITLS{ diff --git a/apis/redpanda/v1alpha1/common_types.go b/apis/redpanda/v1alpha1/common_types.go index e3d23ea9f627..278ff9506e22 100644 --- a/apis/redpanda/v1alpha1/common_types.go +++ b/apis/redpanda/v1alpha1/common_types.go @@ -42,7 +42,7 @@ func (s *SecretKeyRef) GetValue(secret *corev1.Secret, defaultKey string) ([]byt value, ok := secret.Data[key] if !ok { - 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 + 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 } return value, nil } diff --git a/apis/redpanda/v1alpha1/groupversion_info.go b/apis/redpanda/v1alpha1/groupversion_info.go index f6a10d9653ca..06195eeea4ac 100644 --- a/apis/redpanda/v1alpha1/groupversion_info.go +++ b/apis/redpanda/v1alpha1/groupversion_info.go @@ -8,8 +8,8 @@ // by the Apache License, Version 2.0 // Package v1alpha1 contains API Schema definitions for the redpanda v1alpha1 API group -//+kubebuilder:object:generate=true -//+groupName=redpanda.vectorized.io +// +kubebuilder:object:generate=true +// +groupName=redpanda.vectorized.io package v1alpha1 import ( diff --git a/apis/redpanda/v1alpha1/webhook_suite_test.go b/apis/redpanda/v1alpha1/webhook_suite_test.go index 8ee2c833dd93..6919016a09a1 100644 --- a/apis/redpanda/v1alpha1/webhook_suite_test.go +++ b/apis/redpanda/v1alpha1/webhook_suite_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" redpandav1alpha1 "github.com/redpanda-data/redpanda/src/go/k8s/apis/redpanda/v1alpha1" - admissionv1beta1 "k8s.io/api/admission/v1beta1" // nolint:goimports // crlfmt + admissionv1beta1 "k8s.io/api/admission/v1beta1" //nolint:goimports // crlfmt //+kubebuilder:scaffold:imports "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -108,7 +108,7 @@ var _ = BeforeSuite(func() { dialer := &net.Dialer{Timeout: time.Second} addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) Eventually(func() error { - // nolint:gosec // the tests can have insecure verify flag set to true + //nolint:gosec // the tests can have insecure verify flag set to true conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) if err != nil { return err diff --git a/cmd/configurator/main.go b/cmd/configurator/main.go index a6f3eb83f577..d773b02b86ca 100644 --- a/cmd/configurator/main.go +++ b/cmd/configurator/main.go @@ -297,7 +297,7 @@ func getExternalIP(node *corev1.Node) string { return "" } -// nolint:funlen // envs are many +//nolint:funlen // envs are many func checkEnvVars() (configuratorConfig, error) { var result error var extCon string diff --git a/controllers/redpanda/cluster_controller.go b/controllers/redpanda/cluster_controller.go index a24be040da24..572afeb85922 100644 --- a/controllers/redpanda/cluster_controller.go +++ b/controllers/redpanda/cluster_controller.go @@ -80,7 +80,8 @@ type ClusterReconciler struct { // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.7.0/pkg/reconcile -// nolint:funlen // todo break down +// +//nolint:funlen // todo break down func (r *ClusterReconciler) Reconcile( ctx context.Context, req ctrl.Request, ) (ctrl.Result, error) { @@ -297,7 +298,7 @@ func (r *ClusterReconciler) reportStatus( } observedNodesInternal := make([]string, 0, len(observedPods.Items)) - // nolint:gocritic // the copies are necessary for further redpandacluster updates + //nolint:gocritic // the copies are necessary for further redpandacluster updates for _, item := range observedPods.Items { observedNodesInternal = append(observedNodesInternal, fmt.Sprintf("%s.%s", item.Name, internalFQDN)) } @@ -382,7 +383,7 @@ func (r *ClusterReconciler) WithClusterDomain( return r } -// nolint:funlen,gocyclo // External nodes list should be refactored +//nolint:funlen,gocyclo // External nodes list should be refactored func (r *ClusterReconciler) createExternalNodesList( ctx context.Context, pods []corev1.Pod, diff --git a/controllers/redpanda/cluster_controller_configuration.go b/controllers/redpanda/cluster_controller_configuration.go index 47e8551c5533..0610cca48e62 100644 --- a/controllers/redpanda/cluster_controller_configuration.go +++ b/controllers/redpanda/cluster_controller_configuration.go @@ -28,7 +28,8 @@ import ( ) // reconcileConfiguration ensures that the cluster configuration is synchronized with expected data -// nolint:funlen // splitting makes it difficult to follow +// +//nolint:funlen // splitting makes it difficult to follow func (r *ClusterReconciler) reconcileConfiguration( ctx context.Context, redpandaCluster *redpandav1alpha1.Cluster, @@ -345,7 +346,7 @@ func (r *ClusterReconciler) synchronizeStatusWithCluster( return redpandaCluster.Status.GetCondition(conditionData.Type), nil } -// nolint:gocritic // I like this if else chain +//nolint:gocritic // I like this if else chain func mapStatusToCondition( clusterStatus admin.ConfigStatusResponse, ) redpandav1alpha1.ClusterCondition { diff --git a/controllers/redpanda/cluster_controller_configuration_drift.go b/controllers/redpanda/cluster_controller_configuration_drift.go index ed5cbb1a77ab..c5ba1eaa0536 100644 --- a/controllers/redpanda/cluster_controller_configuration_drift.go +++ b/controllers/redpanda/cluster_controller_configuration_drift.go @@ -48,7 +48,8 @@ type ClusterConfigurationDriftReconciler struct { } // Reconcile detects drift in configuration for clusters and schedules a patch. -// nolint:funlen // May be broken down +// +//nolint:funlen // May be broken down func (r *ClusterConfigurationDriftReconciler) Reconcile( ctx context.Context, req ctrl.Request, ) (ctrl.Result, error) { diff --git a/controllers/redpanda/console_controller.go b/controllers/redpanda/console_controller.go index 5667e967f55f..67a31fbb8b2d 100644 --- a/controllers/redpanda/console_controller.go +++ b/controllers/redpanda/console_controller.go @@ -74,7 +74,7 @@ func (r *ConsoleReconciler) Reconcile( } // Checks if Console is valid to be created in specified namespace if !console.IsAllowedNamespace() { - err := fmt.Errorf("invalid Console namespace") // nolint:goerr113 // no need to declare new error type + err := fmt.Errorf("invalid Console namespace") //nolint:goerr113 // no need to declare new error type log.Error(err, "Console must be created in Redpanda namespace. Set --allow-console-any-ns=true to enable") return ctrl.Result{}, err } @@ -159,7 +159,7 @@ func (r *Reconciling) Do( resources.NewIngress(r.Client, console, r.Scheme, subdomain, console.GetName(), consolepkg.ServicePortName, log).WithTLS(resources.LEClusterIssuer, fmt.Sprintf("%s-redpanda", cluster.GetName())), } for _, each := range applyResources { - if err := each.Ensure(ctx); err != nil { // nolint:gocritic // more readable + if err := each.Ensure(ctx); err != nil { //nolint:gocritic // more readable var ra *resources.RequeueAfterError if errors.As(err, &ra) { log.V(debugLogLevel).Info(fmt.Sprintf("Requeue ensuring resource after %d: %s", ra.RequeueAfter, ra.Msg)) diff --git a/controllers/redpanda/console_controller_test.go b/controllers/redpanda/console_controller_test.go index f3229b2bc62b..6f934eadc8ff 100644 --- a/controllers/redpanda/console_controller_test.go +++ b/controllers/redpanda/console_controller_test.go @@ -268,7 +268,7 @@ var _ = Describe("Console controller", func() { var ( googleName = fmt.Sprintf("%s-google", ConsoleName) - googleClientId = "123456654321-abcdefghi123456abcdefghi123456ab.apps.googleusercontent.com" // nolint:stylecheck,revive // Console uses clientId naming + googleClientId = "123456654321-abcdefghi123456abcdefghi123456ab.apps.googleusercontent.com" //nolint:stylecheck // Console uses clientId naming googleClientSecret = "some-random-client-secret" ) diff --git a/controllers/redpanda/suite_test.go b/controllers/redpanda/suite_test.go index 2769946b08d1..6140dd4d7ee1 100644 --- a/controllers/redpanda/suite_test.go +++ b/controllers/redpanda/suite_test.go @@ -355,7 +355,7 @@ func (m *mockAdminAPI) GetFeatures( }, nil } -// nolint:gocritic // It's test API +//nolint:gocritic // It's test API func (m *mockAdminAPI) RegisterPropertySchema( name string, metadata admin.ConfigPropertyMetadata, ) { @@ -422,7 +422,7 @@ func (m *mockAdminAPI) GetNodeConfig( return admin.NodeConfig{}, nil } -// nolint:goerr113 // test code +//nolint:goerr113 // test code func (s *scopedMockAdminAPI) GetNodeConfig( ctx context.Context, ) (admin.NodeConfig, error) { @@ -508,7 +508,7 @@ func (m *mockAdminAPI) DisableMaintenanceMode(_ context.Context, _ int) error { return nil } -// nolint:goerr113 // test code +//nolint:goerr113 // test code func (m *mockAdminAPI) SetBrokerStatus( id int, status admin.MembershipStatus, ) error { diff --git a/main.go b/main.go index 4fc194bc5e18..6e1a70176423 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ var ( setupLog = ctrl.Log.WithName("setup") ) -// nolint:wsl // the init was generated by kubebuilder +//nolint:wsl // the init was generated by kubebuilder func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(redpandav1alpha1.AddToScheme(scheme)) @@ -48,7 +48,7 @@ func init() { //+kubebuilder:scaffold:scheme } -// nolint:funlen // length looks good +//nolint:funlen // length looks good func main() { var ( clusterDomain string diff --git a/pkg/admin/admin.go b/pkg/admin/admin.go index 897e6d29f399..a645160f0df7 100644 --- a/pkg/admin/admin.go +++ b/pkg/admin/admin.go @@ -75,7 +75,8 @@ func NewInternalAdminAPI( } // AdminAPIClient is a sub interface of the admin API containing what we need in the operator -// nolint:revive // usually package is called adminutils +// + type AdminAPIClient interface { Config(ctx context.Context) (admin.Config, error) ClusterConfigStatus(ctx context.Context, sendToLeader bool) (admin.ConfigStatusResponse, error) @@ -99,7 +100,8 @@ type AdminAPIClient interface { var _ AdminAPIClient = &admin.AdminAPI{} // AdminAPIClientFactory is an abstract constructor of admin API clients -// nolint:revive // usually package is called adminutils +// + type AdminAPIClientFactory func( ctx context.Context, k8sClient client.Reader, diff --git a/pkg/console/configmap.go b/pkg/console/configmap.go index 66bf898b41b7..faf89ed9acd0 100644 --- a/pkg/console/configmap.go +++ b/pkg/console/configmap.go @@ -188,7 +188,7 @@ var ( ) func (cm *ConfigMap) genLogin(ctx context.Context) (e EnterpriseLogin, err error) { - if provider := cm.consoleobj.Spec.Login; provider != nil { // nolint:nestif // login config is complex + if provider := cm.consoleobj.Spec.Login; provider != nil { //nolint:nestif // login config is complex enterpriseLogin := EnterpriseLogin{ Enabled: provider.Enabled, } @@ -289,7 +289,7 @@ var ( // REF https://github.com/redpanda-data/console/blob/master/backend/pkg/schema/client.go#L60 DefaultCaFilePath = "/etc/ssl/certs/ca-certificates.crt" - SchemaRegistryTLSDir = "/redpanda/schema-registry" // nolint:revive // readable enough + SchemaRegistryTLSDir = "/redpanda/schema-registry" SchemaRegistryTLSCaFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "ca.crt") SchemaRegistryTLSCertFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "tls.crt") SchemaRegistryTLSKeyFilePath = fmt.Sprintf("%s/%s", SchemaRegistryTLSDir, "tls.key") @@ -469,7 +469,7 @@ func (cm *ConfigMap) delete(ctx context.Context, skip string) error { if err := cm.List(ctx, cms, client.MatchingLabels(labels.ForConsole(cm.consoleobj)), client.InNamespace(cm.consoleobj.GetNamespace())); err != nil { return err } - for _, obj := range cms.Items { // nolint:gocritic // more readable, configmap list is few + for _, obj := range cms.Items { //nolint:gocritic // more readable, configmap list is few if skip != "" && skip == obj.GetName() { continue } diff --git a/pkg/console/console.go b/pkg/console/console.go index 3c03c7e1e8cc..4a69cb52e1ce 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -23,7 +23,7 @@ const ( ) // ConsoleConfig is the config passed to the Redpanda Console app -type ConsoleConfig struct { // nolint:revive // more readable +type ConsoleConfig struct { // Grabbed from https://github.com/redpanda-data/console/ // Copying the config types because they don't have Enterprise fields and not all fields are supported yet MetricsNamespace string `json:"metricsNamespace" yaml:"metricsNamespace"` diff --git a/pkg/console/deployment.go b/pkg/console/deployment.go index a3f1ab5b59d6..b2ccb5fdf89b 100644 --- a/pkg/console/deployment.go +++ b/pkg/console/deployment.go @@ -187,7 +187,7 @@ func (d *Deployment) ensureSyncedSecrets(ctx context.Context) (string, error) { if d.clusterobj.IsSchemaRegistryMutualTLSEnabled() { clientCert, exists := d.store.GetSchemaRegistryClientCert(d.clusterobj) if !exists { - return "", fmt.Errorf("get schema registry client certificate: %s", "not found") // nolint:goerr113 // no need to declare new error type + return "", fmt.Errorf("get schema registry client certificate: %s", "not found") //nolint:goerr113 // no need to declare new error type } certfile := getOrEmpty("tls.crt", clientCert.Data) keyfile := getOrEmpty("tls.key", clientCert.Data) @@ -200,7 +200,7 @@ func (d *Deployment) ensureSyncedSecrets(ctx context.Context) (string, error) { if ca.useCaCert() { caCert, exists := d.store.GetSchemaRegistryNodeCert(d.clusterobj) if !exists { - return "", fmt.Errorf("get schema registry node certificate: %s", "not found") // nolint:goerr113 // no need to declare new error type + return "", fmt.Errorf("get schema registry node certificate: %s", "not found") //nolint:goerr113 // no need to declare new error type } cafile := getOrEmpty("ca.crt", caCert.Data) data["ca.crt"] = []byte(cafile) diff --git a/pkg/console/store.go b/pkg/console/store.go index 538a17a34a65..a8567ce1caa6 100644 --- a/pkg/console/store.go +++ b/pkg/console/store.go @@ -36,7 +36,7 @@ func NewStore(cl client.Client) *Store { // Sync synchronizes watched resources to the store func (s *Store) Sync(cluster *redpandav1alpha1.Cluster) error { - if cluster.IsSchemaRegistryTLSEnabled() { // nolint:nestif // sync is complex + if cluster.IsSchemaRegistryTLSEnabled() { //nolint:nestif // sync is complex if cluster.IsSchemaRegistryMutualTLSEnabled() { schemaRegistryClientCert, err := syncSchemaRegistryCert( s.context, diff --git a/pkg/networking/ports_test.go b/pkg/networking/ports_test.go index f5e6dd07b848..c701ce90c87f 100644 --- a/pkg/networking/ports_test.go +++ b/pkg/networking/ports_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/assert" ) -// nolint:funlen // this is ok for a test +//nolint:funlen // this is ok for a test func TestRedpandaPorts(t *testing.T) { tests := []struct { name string diff --git a/pkg/resources/certmanager/type_helpers_test.go b/pkg/resources/certmanager/type_helpers_test.go index f867b80eebc9..aee332b7d233 100644 --- a/pkg/resources/certmanager/type_helpers_test.go +++ b/pkg/resources/certmanager/type_helpers_test.go @@ -26,7 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -// nolint:funlen // the subtests might causes linter to complain +//nolint:funlen // the subtests might causes linter to complain func TestClusterCertificates(t *testing.T) { secret := corev1.Secret{ ObjectMeta: v1.ObjectMeta{ diff --git a/pkg/resources/cluster_service.go b/pkg/resources/cluster_service.go index 9d4930b7dc37..982bf98cbe90 100644 --- a/pkg/resources/cluster_service.go +++ b/pkg/resources/cluster_service.go @@ -58,7 +58,8 @@ func NewClusterService( } // Ensure will manage kubernetes v1.Service for redpanda.vectorized.io custom resource -// nolint:dupl // TODO multiple services have the same Ensure function +// +//nolint:dupl // TODO multiple services have the same Ensure function func (r *ClusterServiceResource) Ensure(ctx context.Context) error { if len(r.svcPorts) == 0 { return nil diff --git a/pkg/resources/configmap.go b/pkg/resources/configmap.go index f2b77b9096f0..00e9d1403461 100644 --- a/pkg/resources/configmap.go +++ b/pkg/resources/configmap.go @@ -12,7 +12,7 @@ package resources import ( "bytes" "context" - "crypto/md5" // nolint:gosec // this is not encrypting secure info + "crypto/md5" //nolint:gosec // this is not encrypting secure info "crypto/rand" "encoding/json" "errors" @@ -211,7 +211,8 @@ func (r *ConfigMapResource) obj(ctx context.Context) (k8sclient.Object, error) { } // CreateConfiguration creates a global configuration for the current cluster -// nolint:funlen // let's keep the configuration in one function for now and refactor later +// +//nolint:funlen // let's keep the configuration in one function for now and refactor later func (r *ConfigMapResource) CreateConfiguration( ctx context.Context, ) (*configuration.GlobalConfiguration, error) { @@ -650,7 +651,7 @@ func (r *ConfigMapResource) GetNodeConfigHash( } configMap := obj.(*corev1.ConfigMap) configString = configMap.Data[configKey] - md5Hash := md5.Sum([]byte(configString)) // nolint:gosec // this is not encrypting secure info + md5Hash := md5.Sum([]byte(configString)) //nolint:gosec // this is not encrypting secure info return fmt.Sprintf("%x", md5Hash), nil } diff --git a/pkg/resources/configuration/configuration.go b/pkg/resources/configuration/configuration.go index 90ffc453181b..7a66a4dc42ec 100644 --- a/pkg/resources/configuration/configuration.go +++ b/pkg/resources/configuration/configuration.go @@ -11,7 +11,7 @@ package configuration import ( - "crypto/md5" // nolint:gosec // this is not encrypting secure info + "crypto/md5" //nolint:gosec // this is not encrypting secure info "fmt" "reflect" "strings" @@ -69,7 +69,8 @@ func (c *GlobalConfiguration) SetAdditionalRedpandaProperty( } // AppendToAdditionalRedpandaProperty allows appending values to string slices in additional redpanda properties. -// nolint:goerr113 // no need to define static error +// +//nolint:goerr113 // no need to define static error func (c *GlobalConfiguration) AppendToAdditionalRedpandaProperty( key string, value string, ) error { @@ -111,7 +112,7 @@ func (c *GlobalConfiguration) GetCentralizedConfigurationHash( return "", err } // We keep using md5 for having the same format as node hash - md5Hash := md5.Sum(serialized.BootstrapFile) // nolint:gosec // this is not encrypting secure info + md5Hash := md5.Sum(serialized.BootstrapFile) //nolint:gosec // this is not encrypting secure info return fmt.Sprintf("%x", md5Hash), nil } @@ -131,7 +132,7 @@ func (c *GlobalConfiguration) GetNodeConfigurationHash() (string, error) { if err != nil { return "", err } - md5Hash := md5.Sum(serialized.RedpandaFile) // nolint:gosec // this is not encrypting secure info + md5Hash := md5.Sum(serialized.RedpandaFile) //nolint:gosec // this is not encrypting secure info return fmt.Sprintf("%x", md5Hash), nil } diff --git a/pkg/resources/configuration/configuration_modes.go b/pkg/resources/configuration/configuration_modes.go index 8833aa53ccfc..d159ebf4b8b8 100644 --- a/pkg/resources/configuration/configuration_modes.go +++ b/pkg/resources/configuration/configuration_modes.go @@ -165,7 +165,8 @@ func builtInType(value string) bool { } // isEmpty helps to keep the "omitempty" behavior on additional fields -// nolint:exhaustive // just care about these types +// +//nolint:exhaustive // just care about these types func isEmpty(val interface{}) bool { if val == nil { return true diff --git a/pkg/resources/configuration/patch.go b/pkg/resources/configuration/patch.go index 168fd68ba20b..fc728657acfa 100644 --- a/pkg/resources/configuration/patch.go +++ b/pkg/resources/configuration/patch.go @@ -97,7 +97,8 @@ func ThreeWayMerge( // PropertiesEqual tries to compare two property values using metadata information about the schema, // falling back to loose comparison in case of missing data (e.g. it happens with unknown properties). -// nolint:gocritic // code more readable +// +//nolint:gocritic // code more readable func PropertiesEqual( log logr.Logger, v1, v2 interface{}, metadata admin.ConfigPropertyMetadata, ) bool { diff --git a/pkg/resources/configuration/patch_test.go b/pkg/resources/configuration/patch_test.go index 8eb529c3d584..b10ed420ad84 100644 --- a/pkg/resources/configuration/patch_test.go +++ b/pkg/resources/configuration/patch_test.go @@ -132,7 +132,7 @@ func TestString(t *testing.T) { assert.Equal(t, "+a +c -e -f -x", p.String()) } -// nolint:funlen // it's a table test +//nolint:funlen // it's a table test func TestPropertyEquality(t *testing.T) { var nilPointer *int tests := []struct { diff --git a/pkg/resources/ingress.go b/pkg/resources/ingress.go index 85fa728298ea..55068a6d4881 100644 --- a/pkg/resources/ingress.go +++ b/pkg/resources/ingress.go @@ -28,7 +28,7 @@ const ( nginx = "nginx" // SSLPassthroughAnnotation is the annotation for ingress nginx SSL passthrough - SSLPassthroughAnnotation = "nginx.ingress.kubernetes.io/ssl-passthrough" // nolint:gosec // This value does not contain credentials. + SSLPassthroughAnnotation = "nginx.ingress.kubernetes.io/ssl-passthrough" //nolint:gosec // This value does not contain credentials. debugLogLevel = 4 @@ -204,7 +204,7 @@ func objectLabels(obj metav1.Object) (labels.CommonLabels, error) { case *redpandav1alpha1.Console: objLabels = labels.ForConsole(o) default: - return nil, fmt.Errorf("expected object to be Cluster or Console") // nolint:goerr113 // no need to declare new error type + return nil, fmt.Errorf("expected object to be Cluster or Console") //nolint:goerr113 // no need to declare new error type } return objLabels, nil } diff --git a/pkg/resources/lb_service.go b/pkg/resources/lb_service.go index 8ff840985d2d..fd20601ba1fd 100644 --- a/pkg/resources/lb_service.go +++ b/pkg/resources/lb_service.go @@ -61,7 +61,8 @@ func NewLoadBalancerService( } // Ensure manages load-balancer v1.Service for redpanda.vectorized.io -// nolint:dupl // TODO multiple services have the same Ensure function +// +//nolint:dupl // TODO multiple services have the same Ensure function func (r *LoadBalancerServiceResource) Ensure(ctx context.Context) error { if len(r.svcPorts) == 0 { return nil diff --git a/pkg/resources/resource_integration_test.go b/pkg/resources/resource_integration_test.go index 43327f631f4f..8b1e4be08ef7 100644 --- a/pkg/resources/resource_integration_test.go +++ b/pkg/resources/resource_integration_test.go @@ -187,7 +187,7 @@ func TestEnsure_ConfigMap(t *testing.T) { } } -// nolint:funlen // the subtests might causes linter to complain +//nolint:funlen // the subtests might causes linter to complain func TestEnsure_HeadlessService(t *testing.T) { t.Run("create-headless-service", func(t *testing.T) { cluster := pandaCluster() diff --git a/pkg/resources/statefulset.go b/pkg/resources/statefulset.go index 24e3618748a3..96210afce0b4 100644 --- a/pkg/resources/statefulset.go +++ b/pkg/resources/statefulset.go @@ -260,7 +260,8 @@ func preparePVCResource( } // obj returns resource managed client.Object -// nolint:funlen // The complexity of obj function will be address in the next version TODO +// +//nolint:funlen // The complexity of obj function will be address in the next version func (r *StatefulSetResource) obj( ctx context.Context, ) (k8sclient.Object, error) { @@ -279,7 +280,7 @@ func (r *StatefulSetResource) obj( nodeSelector := r.pandaCluster.Spec.NodeSelector if len(r.pandaCluster.Spec.Configuration.KafkaAPI) == 0 { - // TODO + // TODO: Fix this return nil, nil } @@ -610,7 +611,7 @@ func (r *StatefulSetResource) getPostStartHook() *corev1.Handler { } } -// nolint:goconst // no need +//nolint:goconst // no need func (r *StatefulSetResource) composeCURLMaintenanceCommand( options string, urlOverwrite *string, ) string { diff --git a/pkg/resources/statefulset_scale.go b/pkg/resources/statefulset_scale.go index 47b323b0f13a..6b9c6abad56f 100644 --- a/pkg/resources/statefulset_scale.go +++ b/pkg/resources/statefulset_scale.go @@ -64,7 +64,7 @@ const ( // The strategy implemented here (to initialize the cluster at 1 replica, then upscaling to the desired number, without hacks on the seed server list), // should fix this problem, since the list of seeds servers will be the same in all nodes once the cluster is created. // -// nolint:nestif // for clarity +//nolint:nestif // for clarity func (r *StatefulSetResource) handleScaling(ctx context.Context) error { if r.pandaCluster.Status.DecommissioningNode != nil { decommissionTargetReplicas := *r.pandaCluster.Status.DecommissioningNode diff --git a/pkg/resources/statefulset_test.go b/pkg/resources/statefulset_test.go index 6b069a7bda58..4929f5060616 100644 --- a/pkg/resources/statefulset_test.go +++ b/pkg/resources/statefulset_test.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) -// nolint:funlen // Test function can have more than 100 lines +//nolint:funlen // Test function can have more than 100 lines func TestEnsure(t *testing.T) { cluster := pandaCluster() stsResource := stsFromCluster(cluster) diff --git a/pkg/resources/statefulset_update_test.go b/pkg/resources/statefulset_update_test.go index 10e6f36ba8a0..27b6ba763de0 100644 --- a/pkg/resources/statefulset_update_test.go +++ b/pkg/resources/statefulset_update_test.go @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0 -package resources // nolint:testpackage // needed to test private method +package resources //nolint:testpackage // needed to test private method import ( "testing" diff --git a/webhooks/redpanda/console_webhook.go b/webhooks/redpanda/console_webhook.go index f8118a7e4c2f..dccac29560cc 100644 --- a/webhooks/redpanda/console_webhook.go +++ b/webhooks/redpanda/console_webhook.go @@ -25,7 +25,7 @@ type ConsoleValidator struct { // Handle processes admission for Console func (v *ConsoleValidator) Handle( - ctx context.Context, req admission.Request, // nolint:gocritic // interface not require pointer + ctx context.Context, req admission.Request, //nolint:gocritic // interface not require pointer ) admission.Response { console := &redpandav1alpha1.Console{} @@ -88,7 +88,7 @@ type ConsoleDefaulter struct { // Handle processes admission for Console func (m *ConsoleDefaulter) Handle( - ctx context.Context, req admission.Request, // nolint:gocritic // interface not require pointer + ctx context.Context, req admission.Request, //nolint:gocritic // interface not require pointer ) admission.Response { console := &redpandav1alpha1.Console{}