Skip to content

Commit

Permalink
rpk: bump golangci lint to 1.49.0
Browse files Browse the repository at this point in the history
This included some changes in comments formats.
We are also including a timeout of 5m for the
github CI action.
  • Loading branch information
r-vasquez committed Sep 8, 2022
1 parent 42b6d3a commit 6790057
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- name: lint rpk
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
version: v1.49.0
args: --timeout 5m
working-directory: src/go/rpk/

- name: install gofumpt
Expand Down
8 changes: 8 additions & 0 deletions src/go/rpk/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ linters-settings:
require-explanation: true
require-specific: true

# If gofumpt is run outside a module, it assumes Go 1.0 rather than the
# latest Go. We always want the latest formatting.
#
# https://github.com/mvdan/gofumpt/issues/137
gofumpt:
lang-version: "1.17"

# Revive is yet another metalinter with a lot of useful lints.
# The below opts in to all the ones we would like to use.
revive:
Expand Down Expand Up @@ -89,6 +96,7 @@ linters-settings:
- name: modifies-value-receiver
- name: optimize-operands-order
- name: package-comments
disabled: true # disabling this in favor of https://github.com/redpanda-data/redpanda/issues/6340
- name: range
- name: range-val-in-closure
- name: receiver-naming
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/api/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func (a *AdminAPI) sendAndReceive(
// Issue request to the appropriate client, depending on retry behaviour
var res *http.Response
if retryable {
res, err = a.retryClient.Do(req)
res, err = a.retryClient.Do(req) //nolint:contextcheck // False positive in v1.0.9, will be fixed in next release.
} else {
res, err = a.oneshotClient.Do(req)
}
Expand Down
24 changes: 12 additions & 12 deletions src/go/rpk/pkg/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,21 @@ type pluginHandler interface {

// tryExecPlugin looks for a plugin, based on the following rules:
//
// - all "pieces" (non-flags) are joined with an underscore
// - we prefer the longest command match
// - we search upward by piece until we run out of pieces
// - the command must be executable
// - all "pieces" (non-flags) are joined with an underscore
// - we prefer the longest command match
// - we search upward by piece until we run out of pieces
// - the command must be executable
//
// So,
//
// rpk foo-bar baz boz fizz-buzz --flag
// rpk foo-bar baz boz fizz-buzz --flag
//
// is translated into searching and execing (with osPluginHandler), in order:
//
// rpk-foo-bar_baz_boz_fizz-buzz (with args "--flag")
// rpk-foo-bar_baz_boz (with args "fizz-buzz --flag")
// rpk-foo-bar_baz (with args "boz fizz-buzz --flag")
// rpk-foo-bar (with args "baz boz fizz-buzz --flag")
// rpk-foo-bar_baz_boz_fizz-buzz (with args "--flag")
// rpk-foo-bar_baz_boz (with args "fizz-buzz --flag")
// rpk-foo-bar_baz (with args "boz fizz-buzz --flag")
// rpk-foo-bar (with args "baz boz fizz-buzz --flag")
//
// If a plugin is run, this returns the run error and true, otherwise this
// returns false.
Expand Down Expand Up @@ -290,9 +290,9 @@ var (
//
// We expect similar paths to the binary path of a plugin itself:
//
// cloud_foo-bar corresponds to "rpk cloud foo bar"
// cloud_foo_bar corresponds to "rpk cloud foo-bar"
// cloud corresponds to "rpk cloud"
// cloud_foo-bar corresponds to "rpk cloud foo bar"
// cloud_foo_bar corresponds to "rpk cloud foo-bar"
// cloud corresponds to "rpk cloud"
//
// For sanity, all returned paths must begin with the plugin name itself and a
// dash. The only path that can be without a dash is a help for the plugin name
Expand Down
1 change: 0 additions & 1 deletion src/go/rpk/pkg/cli/cmd/topic/consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ func (c *consumer) setParts(
//
// - if !atStart && !atEnd, then we consume at the returned start number
// - rel is used for relative offsets from atStart or atEnd.
//
func parseFromToOffset(
o string,
) (
Expand Down
8 changes: 4 additions & 4 deletions src/go/rpk/pkg/cli/cmd/topic/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ partitions section. By default, the summary and configs sections are printed.
}

// We optionally include the following columns:
// * epoch, if any leader epoch is non-negative
// * offline-replicas, if any are offline
// * load-error, if metadata indicates load errors any partitions
// * last-stable-offset, if it is ever not equal to the high watermark (transactions)
// - epoch, if any leader epoch is non-negative
// - offline-replicas, if any are offline
// - load-error, if metadata indicates load errors any partitions
// - last-stable-offset, if it is ever not equal to the high watermark (transactions)
func getDescribeUsed(
partitions []kmsg.MetadataResponseTopicPartition,
offsets []startStableEndOffset,
Expand Down
25 changes: 12 additions & 13 deletions src/go/rpk/pkg/config/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,11 @@ func ParamsFromCommand(cmd *cobra.Command) *Params {

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

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

// getFieldByTag finds a field with a given yaml tag and returns 3 parameters:
//
// 1. if tag is found within the struct, return the field.
// 2. if tag is not found _but_ the struct has "Other" field, return Other.
// 3. Error if it can't find the given tag and "Other" field is unavailable.
// 1. if tag is found within the struct, return the field.
// 2. if tag is not found _but_ the struct has "Other" field, return Other.
// 3. Error if it can't find the given tag and "Other" field is unavailable.
func getFieldByTag(tag string, v reflect.Value) (reflect.Value, reflect.Value, error) {
t := v.Type()
var other bool
Expand Down
6 changes: 3 additions & 3 deletions src/go/rpk/pkg/net/hostport.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ var labelRe = regexp.MustCompile(`^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$`)
// https://stackoverflow.com/questions/9071279/number-in-the-top-level-domain
// https://www.icann.org/en/system/files/files/ua-factsheet-a4-17dec15-en.pdf
//
// - top level domain should be entirely alphabetic or xn--<alphanumeric>
// to match IDN tld.
// - top level domain can be anywhere from two to 63 characters long.
// - top level domain should be entirely alphabetic or xn--<alphanumeric>
// to match IDN tld.
// - top level domain can be anywhere from two to 63 characters long.
var tldRe = regexp.MustCompile(`^(?:[a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{1,59})$`)

// Returns whether the input is an ip address.
Expand Down
44 changes: 25 additions & 19 deletions src/go/rpk/pkg/tuners/irq/irq_tuner_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@
package irq

/*
Modes are ordered from the one that cuts the biggest number of CPUs
from the compute CPUs' set to the one that takes the smallest ('mq' doesn't
cut any CPU from the compute set).
This fact is used when we calculate the 'common quotient' mode out of a
given set of modes (e.g. default modes of different Tuners) - this would
be the smallest among the given modes.
Modes description:
sq - set all IRQs of a given NIC to CPU0 and configure RPS
to spreads NAPIs' handling between other CPUs.
sq_split - divide all IRQs of a given NIC between CPU0 and its HT siblings and configure RPS
to spreads NAPIs' handling between other CPUs.
mq - distribute NIC's IRQs among all CPUs instead of binding
them all to CPU0. In this mode RPS is always enabled to
spreads NAPIs' handling between all CPUs.
If there isn't any mode given script will use a default mode:
- If number of physical CPU cores per Rx HW queue is greater than 4 - use the 'sq-split' mode.
- Otherwise, if number of hyperthreads per Rx HW queue is greater than 4 - use the 'sq' mode.
- Otherwise use the 'mq' mode.
Modes are ordered from the one that cuts the biggest number of CPUs
from the compute CPUs' set to the one that takes the smallest ('mq' doesn't
cut any CPU from the compute set).
This fact is used when we calculate the 'common quotient' mode out of a
given set of modes (e.g. default modes of different Tuners) - this would
be the smallest among the given modes.
Modes description:
sq - set all IRQs of a given NIC to CPU0 and configure RPS
to spreads NAPIs' handling between other CPUs.
sq_split - divide all IRQs of a given NIC between CPU0 and its HT siblings and configure RPS
to spreads NAPIs' handling between other CPUs.
mq - distribute NIC's IRQs among all CPUs instead of binding
them all to CPU0. In this mode RPS is always enabled to
spreads NAPIs' handling between all CPUs.
If there isn't any mode given script will use a default mode:
- If number of physical CPU cores per Rx HW queue is greater than 4 - use the 'sq-split' mode.
- Otherwise, if number of hyperthreads per Rx HW queue is greater than 4 - use the 'sq' mode.
- Otherwise use the 'mq' mode.
*/
type Mode string

Expand Down

0 comments on commit 6790057

Please sign in to comment.