Skip to content

Commit 3793725

Browse files
committed
rpk: bump golangci lint to 1.49.0
This included some changes in comments formats. We are also including a timeout of 5m for the github CI action.
1 parent acf64f1 commit 3793725

File tree

9 files changed

+67
-54
lines changed

9 files changed

+67
-54
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
- name: lint rpk
3636
uses: golangci/golangci-lint-action@v3
3737
with:
38-
version: v1.45.2
38+
version: v1.49.0
39+
args: --timeout 5m
3940
working-directory: src/go/rpk/
4041

4142
- name: install gofumpt

src/go/rpk/.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ linters-settings:
5858
require-explanation: true
5959
require-specific: true
6060

61+
# If gofumpt is run outside a module, it assumes Go 1.0 rather than the
62+
# latest Go. We always want the latest formatting.
63+
#
64+
# https://github.com/mvdan/gofumpt/issues/137
65+
gofumpt:
66+
lang-version: "1.17"
67+
6168
# Revive is yet another metalinter with a lot of useful lints.
6269
# The below opts in to all the ones we would like to use.
6370
revive:
@@ -89,6 +96,7 @@ linters-settings:
8996
- name: modifies-value-receiver
9097
- name: optimize-operands-order
9198
- name: package-comments
99+
disabled: true # disabling this in favor of https://github.com/redpanda-data/redpanda/issues/6340
92100
- name: range
93101
- name: range-val-in-closure
94102
- name: receiver-naming

src/go/rpk/pkg/api/admin/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ func (a *AdminAPI) sendAndReceive(
546546
// Issue request to the appropriate client, depending on retry behaviour
547547
var res *http.Response
548548
if retryable {
549-
res, err = a.retryClient.Do(req)
549+
res, err = a.retryClient.Do(req) //nolint:contextcheck // False positive in v1.0.9, will be fixed in next release.
550550
} else {
551551
res, err = a.oneshotClient.Do(req)
552552
}

src/go/rpk/pkg/cli/cmd/root.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,21 @@ type pluginHandler interface {
152152

153153
// tryExecPlugin looks for a plugin, based on the following rules:
154154
//
155-
// - all "pieces" (non-flags) are joined with an underscore
156-
// - we prefer the longest command match
157-
// - we search upward by piece until we run out of pieces
158-
// - the command must be executable
155+
// - all "pieces" (non-flags) are joined with an underscore
156+
// - we prefer the longest command match
157+
// - we search upward by piece until we run out of pieces
158+
// - the command must be executable
159159
//
160160
// So,
161161
//
162-
// rpk foo-bar baz boz fizz-buzz --flag
162+
// rpk foo-bar baz boz fizz-buzz --flag
163163
//
164164
// is translated into searching and execing (with osPluginHandler), in order:
165165
//
166-
// rpk-foo-bar_baz_boz_fizz-buzz (with args "--flag")
167-
// rpk-foo-bar_baz_boz (with args "fizz-buzz --flag")
168-
// rpk-foo-bar_baz (with args "boz fizz-buzz --flag")
169-
// rpk-foo-bar (with args "baz boz fizz-buzz --flag")
166+
// rpk-foo-bar_baz_boz_fizz-buzz (with args "--flag")
167+
// rpk-foo-bar_baz_boz (with args "fizz-buzz --flag")
168+
// rpk-foo-bar_baz (with args "boz fizz-buzz --flag")
169+
// rpk-foo-bar (with args "baz boz fizz-buzz --flag")
170170
//
171171
// If a plugin is run, this returns the run error and true, otherwise this
172172
// returns false.
@@ -290,9 +290,9 @@ var (
290290
//
291291
// We expect similar paths to the binary path of a plugin itself:
292292
//
293-
// cloud_foo-bar corresponds to "rpk cloud foo bar"
294-
// cloud_foo_bar corresponds to "rpk cloud foo-bar"
295-
// cloud corresponds to "rpk cloud"
293+
// cloud_foo-bar corresponds to "rpk cloud foo bar"
294+
// cloud_foo_bar corresponds to "rpk cloud foo-bar"
295+
// cloud corresponds to "rpk cloud"
296296
//
297297
// For sanity, all returned paths must begin with the plugin name itself and a
298298
// dash. The only path that can be without a dash is a help for the plugin name

src/go/rpk/pkg/cli/cmd/topic/consume.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ func (c *consumer) setParts(
354354
//
355355
// - if !atStart && !atEnd, then we consume at the returned start number
356356
// - rel is used for relative offsets from atStart or atEnd.
357-
//
358357
func parseFromToOffset(
359358
o string,
360359
) (

src/go/rpk/pkg/cli/cmd/topic/describe.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ partitions section. By default, the summary and configs sections are printed.
188188
}
189189

190190
// We optionally include the following columns:
191-
// * epoch, if any leader epoch is non-negative
192-
// * offline-replicas, if any are offline
193-
// * load-error, if metadata indicates load errors any partitions
194-
// * last-stable-offset, if it is ever not equal to the high watermark (transactions)
191+
// - epoch, if any leader epoch is non-negative
192+
// - offline-replicas, if any are offline
193+
// - load-error, if metadata indicates load errors any partitions
194+
// - last-stable-offset, if it is ever not equal to the high watermark (transactions)
195195
func getDescribeUsed(
196196
partitions []kmsg.MetadataResponseTopicPartition,
197197
offsets []startStableEndOffset,

src/go/rpk/pkg/config/params.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,11 @@ func ParamsFromCommand(cmd *cobra.Command) *Params {
232232

233233
// Load returns the param's config file. In order, this
234234
//
235-
// * Finds the config file, per the --config flag or the default search set.
236-
// * Decodes the config over the default configuration.
237-
// * Back-compats any old format into any new format.
238-
// * Processes env and flag overrides.
239-
// * Sets unset default values.
240-
//
235+
// - Finds the config file, per the --config flag or the default search set.
236+
// - Decodes the config over the default configuration.
237+
// - Back-compats any old format into any new format.
238+
// - Processes env and flag overrides.
239+
// - Sets unset default values.
241240
func (p *Params) Load(fs afero.Fs) (*Config, error) {
242241
// If we have a config path loaded (through --config flag) the user
243242
// expect to load or create the file from this directory.
@@ -554,10 +553,10 @@ func (c *Config) addUnsetDefaults() {
554553

555554
// Set allow to set a single configuration field by passing a key value pair
556555
//
557-
// Key: string containing the yaml field tags, e.g: 'rpk.admin_api'.
558-
// Value: string representation of the value, either single value or partial
559-
// representation.
560-
// Format: either json or yaml (default: yaml).
556+
// Key: string containing the yaml field tags, e.g: 'rpk.admin_api'.
557+
// Value: string representation of the value, either single value or partial
558+
// representation.
559+
// Format: either json or yaml (default: yaml).
561560
func (c *Config) Set(key, value, format string) error {
562561
if key == "" {
563562
return fmt.Errorf("key field must not be empty")
@@ -687,9 +686,9 @@ func getField(tags []string, parentRawTag string, v reflect.Value) (reflect.Valu
687686

688687
// getFieldByTag finds a field with a given yaml tag and returns 3 parameters:
689688
//
690-
// 1. if tag is found within the struct, return the field.
691-
// 2. if tag is not found _but_ the struct has "Other" field, return Other.
692-
// 3. Error if it can't find the given tag and "Other" field is unavailable.
689+
// 1. if tag is found within the struct, return the field.
690+
// 2. if tag is not found _but_ the struct has "Other" field, return Other.
691+
// 3. Error if it can't find the given tag and "Other" field is unavailable.
693692
func getFieldByTag(tag string, v reflect.Value) (reflect.Value, reflect.Value, error) {
694693
t := v.Type()
695694
var other bool

src/go/rpk/pkg/net/hostport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ var labelRe = regexp.MustCompile(`^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$`)
151151
// https://stackoverflow.com/questions/9071279/number-in-the-top-level-domain
152152
// https://www.icann.org/en/system/files/files/ua-factsheet-a4-17dec15-en.pdf
153153
//
154-
// - top level domain should be entirely alphabetic or xn--<alphanumeric>
155-
// to match IDN tld.
156-
// - top level domain can be anywhere from two to 63 characters long.
154+
// - top level domain should be entirely alphabetic or xn--<alphanumeric>
155+
// to match IDN tld.
156+
// - top level domain can be anywhere from two to 63 characters long.
157157
var tldRe = regexp.MustCompile(`^(?:[a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{1,59})$`)
158158

159159
// Returns whether the input is an ip address.

src/go/rpk/pkg/tuners/irq/irq_tuner_mode.go

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,31 @@
1010
package irq
1111

1212
/*
13-
Modes are ordered from the one that cuts the biggest number of CPUs
14-
from the compute CPUs' set to the one that takes the smallest ('mq' doesn't
15-
cut any CPU from the compute set).
16-
This fact is used when we calculate the 'common quotient' mode out of a
17-
given set of modes (e.g. default modes of different Tuners) - this would
18-
be the smallest among the given modes.
19-
20-
Modes description:
21-
sq - set all IRQs of a given NIC to CPU0 and configure RPS
22-
to spreads NAPIs' handling between other CPUs.
23-
sq_split - divide all IRQs of a given NIC between CPU0 and its HT siblings and configure RPS
24-
to spreads NAPIs' handling between other CPUs.
25-
mq - distribute NIC's IRQs among all CPUs instead of binding
26-
them all to CPU0. In this mode RPS is always enabled to
27-
spreads NAPIs' handling between all CPUs.
28-
If there isn't any mode given script will use a default mode:
29-
- If number of physical CPU cores per Rx HW queue is greater than 4 - use the 'sq-split' mode.
30-
- Otherwise, if number of hyperthreads per Rx HW queue is greater than 4 - use the 'sq' mode.
31-
- Otherwise use the 'mq' mode.
13+
Modes are ordered from the one that cuts the biggest number of CPUs
14+
from the compute CPUs' set to the one that takes the smallest ('mq' doesn't
15+
cut any CPU from the compute set).
16+
This fact is used when we calculate the 'common quotient' mode out of a
17+
given set of modes (e.g. default modes of different Tuners) - this would
18+
be the smallest among the given modes.
19+
20+
Modes description:
21+
sq - set all IRQs of a given NIC to CPU0 and configure RPS
22+
23+
to spreads NAPIs' handling between other CPUs.
24+
25+
sq_split - divide all IRQs of a given NIC between CPU0 and its HT siblings and configure RPS
26+
27+
to spreads NAPIs' handling between other CPUs.
28+
29+
mq - distribute NIC's IRQs among all CPUs instead of binding
30+
31+
them all to CPU0. In this mode RPS is always enabled to
32+
spreads NAPIs' handling between all CPUs.
33+
34+
If there isn't any mode given script will use a default mode:
35+
- If number of physical CPU cores per Rx HW queue is greater than 4 - use the 'sq-split' mode.
36+
- Otherwise, if number of hyperthreads per Rx HW queue is greater than 4 - use the 'sq' mode.
37+
- Otherwise use the 'mq' mode.
3238
*/
3339
type Mode string
3440

0 commit comments

Comments
 (0)