Skip to content

Commit a6531c2

Browse files
authored
chore(ci): upgrade golangci-lint (#2459)
1 parent 5472371 commit a6531c2

File tree

33 files changed

+103
-111
lines changed

33 files changed

+103
-111
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: |
4141
make vet
4242
- name: Lint
43-
uses: golangci/golangci-lint-action@v6
43+
uses: golangci/golangci-lint-action@v8
4444
with:
4545
args: --build-tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper,exclude_graphdriver_overlay
4646

.golangci.yml

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,37 @@
1-
run:
2-
timeout: 10m
3-
4-
output:
5-
# Make output more digestible with quickfix in vim/emacs/etc.
6-
sort-results: true
7-
print-issued-lines: false
8-
1+
version: "2"
92
linters:
10-
# We'll track the golangci-lint default linters manually
11-
# instead of letting them change without our control.
12-
disable-all: true
3+
default: none
134
enable:
14-
# golangci-lint defaults:
15-
# - errcheck
16-
- gosimple
175
- govet
186
- ineffassign
7+
- nolintlint
198
- staticcheck
20-
# - unused
21-
22-
# Our own extras:
23-
- gofmt
24-
- nolintlint # lints nolint directives
25-
# - revive
26-
27-
linters-settings:
28-
govet:
29-
# These govet checks are disabled by default, but they're useful.
30-
enable:
31-
- nilness
32-
- reflectvaluecompare
33-
- sortslice
34-
- unusedwrite
35-
unused:
36-
field-writes-are-uses: false
37-
exported-fields-are-used: false
38-
# parameters-are-used: false
39-
local-variables-are-used: false
40-
9+
settings:
10+
govet:
11+
enable:
12+
- nilness
13+
- reflectvaluecompare
14+
- sortslice
15+
- unusedwrite
16+
unused:
17+
field-writes-are-uses: false
18+
exported-fields-are-used: false
19+
local-variables-are-used: false
20+
exclusions:
21+
generated: lax
22+
paths:
23+
- third_party$
24+
- builtin$
25+
- examples$
4126
issues:
42-
# Print all issues reported by all linters.
4327
max-issues-per-linter: 0
4428
max-same-issues: 0
45-
46-
# Don't ignore some of the issues that golangci-lint considers okay.
47-
# This includes documenting all exported entities.
48-
exclude-use-default: false
29+
formatters:
30+
enable:
31+
- gofmt
32+
exclusions:
33+
generated: lax
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$

api/integration/linux/install/infra_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/replicatedhq/embedded-cluster/api/integration"
2020
"github.com/replicatedhq/embedded-cluster/api/integration/assets"
2121
"github.com/replicatedhq/embedded-cluster/api/integration/auth"
22-
"github.com/replicatedhq/embedded-cluster/api/internal/managers/linux/infra"
2322
linuxinfra "github.com/replicatedhq/embedded-cluster/api/internal/managers/linux/infra"
2423
"github.com/replicatedhq/embedded-cluster/api/internal/managers/linux/preflight"
2524
linuxpreflightstore "github.com/replicatedhq/embedded-cluster/api/internal/store/linux/preflight"
@@ -686,10 +685,10 @@ func TestLinuxPostSetupInfra(t *testing.T) {
686685
pfManager := preflight.NewHostPreflightManager(
687686
preflight.WithHostPreflightStore(linuxpreflightstore.NewMemoryStore(linuxpreflightstore.WithHostPreflight(hpf))),
688687
)
689-
infraManager := infra.NewInfraManager(
690-
infra.WithK0s(k0sMock),
691-
infra.WithHostUtils(hostutilsMock),
692-
infra.WithLicense(assets.LicenseData),
688+
infraManager := linuxinfra.NewInfraManager(
689+
linuxinfra.WithK0s(k0sMock),
690+
linuxinfra.WithHostUtils(hostutilsMock),
691+
linuxinfra.WithLicense(assets.LicenseData),
693692
)
694693

695694
// Setup k0s mock expectations with failure

api/internal/handlers/kubernetes/kubernetes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func New(cfg types.APIConfig, opts ...Option) (*Handler, error) {
6060
install.WithConfigValues(h.cfg.ConfigValues),
6161
install.WithEndUserConfig(h.cfg.EndUserConfig),
6262
install.WithPassword(h.cfg.Password),
63+
//nolint:staticcheck // QF1008 this is very ambiguous, we should re-think the config struct
6364
install.WithInstallation(h.cfg.KubernetesConfig.Installation),
6465
)
6566
if err != nil {

api/internal/managers/linux/infra/install.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
const K0sComponentName = "Runtime"
3333

3434
func AlreadyInstalledError() error {
35+
//nolint:staticcheck // ST1005 TODO: use a constant here and print a better error message
3536
return fmt.Errorf(
3637
"\nAn installation is detected on this machine.\nTo install, you must first remove the existing installation.\nYou can do this by running the following command:\n\n sudo ./%s reset\n",
3738
runtimeconfig.AppSlug(),

api/internal/statemachine/event_handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (eh *eventHandler) TriggerHandler(ctx context.Context, fromState, toState S
6060
defer func() {
6161
if r := recover(); r != nil {
6262
// Capture panic but don't affect the transition
63+
//nolint:staticcheck // ST1005 not sure why we need a newline here
6364
err := fmt.Errorf("event handler panic from %s to %s: %v: %s\n", fromState, toState, r, debug.Stack())
6465
done <- err
6566
}

cmd/installer/cli/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ func preRunInstallKubernetes(_ *cobra.Command, flags *InstallCmdFlags, _ kuberne
540540
return fmt.Errorf("failed to connect to kubernetes api server: %w", err)
541541
}
542542

543-
flags.installConfig.kubernetesRESTClientGetter = flags.kubernetesEnvSettings.RESTClientGetter()
543+
flags.kubernetesRESTClientGetter = flags.kubernetesEnvSettings.RESTClientGetter()
544544

545545
return nil
546546
}
@@ -665,7 +665,7 @@ func runManagerExperienceInstall(
665665
AllowIgnoreHostPreflights: flags.ignoreHostPreflights,
666666
},
667667
KubernetesConfig: apitypes.KubernetesConfig{
668-
RESTClientGetter: flags.installConfig.kubernetesRESTClientGetter,
668+
RESTClientGetter: flags.kubernetesRESTClientGetter,
669669
Installation: ki,
670670
},
671671
},

cmd/installer/cli/logging.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/replicatedhq/embedded-cluster/pkg/versions"
1313
"github.com/sirupsen/logrus"
1414
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
15-
"sigs.k8s.io/controller-runtime/pkg/log/zap"
1615
ctrlzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
1716
)
1817

@@ -127,7 +126,7 @@ func SetupLogging() {
127126

128127
// setupCtrlLogging sets up the logging for the controller-runtime package to the writer specified.
129128
func setupCtrlLogging(w io.Writer) {
130-
k8slogger := ctrlzap.New(func(o *zap.Options) {
129+
k8slogger := ctrlzap.New(func(o *ctrlzap.Options) {
131130
o.DestWriter = w
132131
})
133132
ctrllog.SetLogger(k8slogger)

cmd/installer/cli/restore.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,8 @@ func waitForDRComponent(ctx context.Context, drComponent disasterRecoveryCompone
13961396
return fmt.Errorf("unable to wait for velero restore to complete: %w", err)
13971397
}
13981398

1399-
if drComponent == disasterRecoveryComponentAdminConsole {
1399+
switch drComponent {
1400+
case disasterRecoveryComponentAdminConsole:
14001401
// wait for admin console to be ready
14011402
kcli, err := kubeutils.KubeClient()
14021403
if err != nil {
@@ -1406,7 +1407,7 @@ func waitForDRComponent(ctx context.Context, drComponent disasterRecoveryCompone
14061407
if err := restoreWaitForAdminConsoleReady(ctx, kcli, constants.KotsadmNamespace, loading); err != nil {
14071408
return fmt.Errorf("unable to wait for admin console: %w", err)
14081409
}
1409-
} else if drComponent == disasterRecoveryComponentSeaweedFS {
1410+
case disasterRecoveryComponentSeaweedFS:
14101411
// wait for seaweedfs to be ready
14111412
kcli, err := kubeutils.KubeClient()
14121413
if err != nil {
@@ -1416,7 +1417,7 @@ func waitForDRComponent(ctx context.Context, drComponent disasterRecoveryCompone
14161417
if err := restoreWaitForSeaweedfsReady(ctx, kcli, constants.SeaweedFSNamespace, nil); err != nil {
14171418
return fmt.Errorf("unable to wait for seaweedfs to be ready: %w", err)
14181419
}
1419-
} else if drComponent == disasterRecoveryComponentRegistry {
1420+
case disasterRecoveryComponentRegistry:
14201421
// wait for registry to be ready
14211422
kcli, err := kubeutils.KubeClient()
14221423
if err != nil {
@@ -1426,7 +1427,7 @@ func waitForDRComponent(ctx context.Context, drComponent disasterRecoveryCompone
14261427
if err := kubeutils.WaitForDeployment(ctx, kcli, constants.RegistryNamespace, "registry", nil); err != nil {
14271428
return fmt.Errorf("unable to wait for registry to be ready: %w", err)
14281429
}
1429-
} else if drComponent == disasterRecoveryComponentECO {
1430+
case disasterRecoveryComponentECO:
14301431
// wait for embedded cluster operator to reconcile the installation
14311432
kcli, err := kubeutils.KubeClient()
14321433
if err != nil {

cmd/local-artifact-mirror/serve_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ func TestServeCmd(t *testing.T) {
135135
url := "http://127.0.0.1:" + port + tc.filePath
136136
resp, err := http.Get(url)
137137

138-
if tc.expectCode == http.StatusOK {
138+
switch tc.expectCode {
139+
case http.StatusOK:
139140
require.NoError(t, err, "HTTP request should not fail")
140141
defer resp.Body.Close()
141142

@@ -144,7 +145,7 @@ func TestServeCmd(t *testing.T) {
144145
body, err := io.ReadAll(resp.Body)
145146
require.NoError(t, err)
146147
assert.Equal(t, tc.expectBody, string(body))
147-
} else if tc.expectCode == http.StatusNotFound {
148+
case http.StatusNotFound:
148149
if err == nil {
149150
defer resp.Body.Close()
150151
assert.Equal(t, tc.expectCode, resp.StatusCode)

0 commit comments

Comments
 (0)