Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/lint-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Setup go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: stable
cache-dependency-path: src/go/rpk/go.mod
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout 10m --verbose
Expand Down
10 changes: 5 additions & 5 deletions src/go/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev={{.ShortCommit}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime={{.Date}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag={{.Tag}}
env:
- CGO_ENABLED=0
goos:
Expand All @@ -26,7 +26,7 @@ builds:
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev={{.ShortCommit}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime={{.Date}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag={{.Tag}}
env:
- 'CGO_ENABLED={{ if index .Env "CGO_ENABLED" }}{{ .Env.CGO_ENABLED }}{{ else }}0{{ end }}'
tags:
Expand All @@ -44,7 +44,7 @@ builds:
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev={{.ShortCommit}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime={{.Date}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag={{.Tag}}
env:
- CGO_ENABLED=0
goos:
Expand All @@ -60,7 +60,7 @@ builds:
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev={{.ShortCommit}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime={{.Date}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag={{.Tag}}
env:
- CGO_ENABLED=0
goos:
Expand All @@ -76,7 +76,7 @@ builds:
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev={{.ShortCommit}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime={{.Date}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag={{.Tag}}
- -X github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag={{.Tag}}
env:
- CGO_ENABLED=0
goos:
Expand Down
176 changes: 90 additions & 86 deletions src/go/rpk/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
version: "2"
run:
allow-parallel-runners: true
tests: false

# golangci-lint by default ignores some staticcheck and vet raised issues that
# are actually important to catch. The following ensures that we do not ignore
# those tools ever.
issues:
exclude-use-default: false

# We opt out of all suggested linters and manually pick what we want.
# Please do not use enable-all.
allow-parallel-runners: true
linters:
disable-all: true
# golangci-lint by default ignores some staticcheck and vet raised issues that
# are actually important to catch. The following ensures that we do not ignore
# those tools ever.
default: none
# We opt out of all suggested linters and manually pick what we want.
# Please do not use enable-all.
enable:
# Enabled by default linters:
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# Disabled by default
- asciicheck
- bidichk
- bodyclose
Expand All @@ -29,79 +18,94 @@ linters:
- errname
- errorlint
- godot
- gofmt
- gofumpt
- goimports
- goprintffuncname
- govet
- ineffassign
- misspell
- nilerr
- noctx
- nolintlint
- revive
- usetesting
- staticcheck
- unconvert
- unused
- usetesting
- wastedassign
- whitespace

linters-settings:
# We do not want to enforce every usage of fmt.Errorf to use %w.
errorlint:
errorf: false

# If we want to opt out of a lint, we require an explanation.
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true

# 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:
ignore-generated-header: true
severity: warning
confidence: 0.6
rules:
- name: atomic
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: error-naming
- name: error-return
- name: error-strings
arguments:
- out.Die
- out.MaybeDie
- out.DieString
- out.MaybeDieString
- name: get-return
- name: identical-branches
- name: if-return
- 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
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unconditional-recursion
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
- name: unused-receiver
- name: useless-break
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
settings:
errorlint:
# We do not want to enforce every usage of fmt.Errorf to use %w.
errorf: false
nolintlint:
# If we want to opt out of a lint, we require an explanation.
require-explanation: true
require-specific: true
allow-unused: false
# 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:
confidence: 0.6
severity: warning
rules:
- name: atomic
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: error-naming
- name: error-return
- name: error-strings
exclude: ["Redpanda"]
arguments:
- out.Die
- out.MaybeDie
- out.DieString
- out.MaybeDieString
- name: get-return
- name: identical-branches
- name: if-return
- name: modifies-value-receiver
- name: optimize-operands-order
- name: package-comments
disabled: true
- name: range
- name: range-val-in-closure
- name: receiver-naming
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unconditional-recursion
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
- name: unused-receiver
- name: useless-break
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion src/go/rpk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ VER := $(or $(VERSION),local-dev)
IMG_TAG:= $(or $(VERSION),latest)
BUILD_TIME=$(shell date -Iseconds)
VER_PKG='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version'
CONT_PKG='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common'
CONT_PKG='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil'

LDFLAGS=-X $(VER_PKG).version=$(VER) -X $(VER_PKG).rev=$(REV) -X $(CONT_PKG).tag=$(IMG_TAG) -X ${VER_PKG}.hostOs=${GOOS} -X ${VER_PKG}.hostArch=${GOARCH} -X ${VER_PKG}.buildTime=${BUILD_TIME}

Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ out_dir="$(go env GOOS)-$(go env GOARCH)"
mkdir -p "${out_dir}"

ver_pkg='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version'
cont_pkg='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common'
cont_pkg='github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil'

go build \
-ldflags "-X ${ver_pkg}.version=${version} -X ${ver_pkg}.rev=${rev} -X ${cont_pkg}.tag=${img_tag} -X ${ver_pkg}.buildTime=${buildTime} -X ${ver_pkg}.hostOs=${hostOs} -X ${ver_pkg}.hostArch=${hostArch}" \
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/cmd/rpk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go_binary(
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.version": "{STABLE_GIT_LATEST_TAG}",
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.rev": "{STABLE_GIT_COMMIT}",
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/version.buildTime": "{FORMATTED_DATE}",
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common.tag": "{STABLE_GIT_LATEST_TAG}",
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil.tag": "{STABLE_GIT_LATEST_TAG}",
},
)

Expand Down
4 changes: 2 additions & 2 deletions src/go/rpk/pkg/cli/cloud/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ go_library(
"//src/go/rpk/pkg/cli/cloud/cluster",
"//src/go/rpk/pkg/cli/cloud/mcp",
"//src/go/rpk/pkg/cli/cloud/resourcegroup",
"//src/go/rpk/pkg/cli/container/common",
"//src/go/rpk/pkg/cli/container/containerutil",
"//src/go/rpk/pkg/cli/profile",
"//src/go/rpk/pkg/config",
"//src/go/rpk/pkg/oauth",
"//src/go/rpk/pkg/oauth/providers/auth0",
"//src/go/rpk/pkg/os",
"//src/go/rpk/pkg/osutil",
"//src/go/rpk/pkg/out",
"@com_github_spf13_afero//:afero",
"@com_github_spf13_cobra//:cobra",
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/cloud/byoc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
"//src/go/rpk/pkg/config",
"//src/go/rpk/pkg/oauth",
"//src/go/rpk/pkg/oauth/providers/auth0",
"//src/go/rpk/pkg/os",
"//src/go/rpk/pkg/osutil",
"//src/go/rpk/pkg/out",
"//src/go/rpk/pkg/plugin",
"//src/go/rpk/pkg/publicapi",
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/cloud/byoc/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/oauth"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/oauth/providers/auth0"
rpkos "github.com/redpanda-data/redpanda/src/go/rpk/pkg/os"
rpkos "github.com/redpanda-data/redpanda/src/go/rpk/pkg/osutil"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/out"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/plugin"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/publicapi"
Expand Down
6 changes: 3 additions & 3 deletions src/go/rpk/pkg/cli/cloud/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package cloud
import (
"fmt"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/common"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/container/containerutil"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/profile"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/oauth"
Expand Down Expand Up @@ -137,7 +137,7 @@ rpk will talk to a localhost:9092 cluster until you swap to a different profile.
// unless the user used --no-profile.
if noProfile {
// The current profile is seemingly pointing to a container cluster.
if p.Name == common.ContainerProfileName {
if p.Name == containerutil.ContainerProfileName {
fmt.Printf("You are talking to a localhost 'rpk container' cluster (rpk profile name: %q)\n", p.Name)
fmt.Println("To talk to a cloud cluster, use 'rpk cloud cluster select'.")
return
Expand All @@ -158,7 +158,7 @@ rpk will talk to a localhost:9092 cluster until you swap to a different profile.
return
}

if p.Name == common.ContainerProfileName {
if p.Name == containerutil.ContainerProfileName {
fmt.Printf("You are talking to a localhost 'rpk container' cluster (rpk profile name: %q)\n", p.Name)
} else {
fmt.Printf("You are talking to a self hosted cluster (rpk profile name: %q)\n", p.Name)
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/cloud/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"fmt"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
rpkos "github.com/redpanda-data/redpanda/src/go/rpk/pkg/os"
rpkos "github.com/redpanda-data/redpanda/src/go/rpk/pkg/osutil"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/out"
"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/cloud/mcp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_library(
"//src/go/rpk/pkg/config",
"//src/go/rpk/pkg/oauth/authtoken",
"//src/go/rpk/pkg/oauth/providers/auth0",
"//src/go/rpk/pkg/os",
"//src/go/rpk/pkg/osutil",
"//src/go/rpk/pkg/out",
"//src/go/rpk/pkg/publicapi",
"@build_buf_gen_go_redpandadata_cloud_protocolbuffers_go//redpanda/api/controlplane/v1:controlplane",
Expand Down
Loading
Loading