Skip to content

Commit 8b4595d

Browse files
authored
Merge pull request #1101 from SergeyKanzhelev/format-imports
format imports
2 parents 414d248 + 75bf501 commit 8b4595d

38 files changed

+95
-81
lines changed

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ issues:
1919
max-issues-per-linter: 0
2020
max-same-issues: 0
2121
formatters:
22+
enable:
23+
- gci
24+
- gofmt
25+
- gofumpt
26+
- goimports
27+
settings:
28+
gci:
29+
sections:
30+
- standard
31+
- default
32+
- localmodule
33+
goimports:
34+
local-prefixes:
35+
- k8s.io/node-problem-detector
2236
exclusions:
2337
generated: lax
2438
paths:

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ vet:
130130
grep -v "./vendor/*" | \
131131
xargs go vet -tags "$(HOST_PLATFORM_BUILD_TAGS)"
132132

133-
fmt:
133+
fmt: $(GOLANGCI_LINT)
134134
find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l
135+
$(GOLANGCI_LINT) run --config .golangci.yml --fix ./...
135136

136137
version:
137138
@echo $(VERSION)

cmd/healthchecker/health_checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"os"
2323

2424
"github.com/spf13/pflag"
25-
2625
"k8s.io/klog/v2"
26+
2727
"k8s.io/node-problem-detector/cmd/healthchecker/options"
2828
"k8s.io/node-problem-detector/pkg/custompluginmonitor/types"
2929
"k8s.io/node-problem-detector/pkg/healthchecker"

cmd/nodeproblemdetector/node_problem_detector_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ func init() {
7171
})
7272
}
7373

74-
type nullExporter struct {
75-
}
74+
type nullExporter struct{}
7675

7776
func (ne *nullExporter) ExportProblems(*types.Status) {
7877
}
@@ -96,7 +95,7 @@ func writeTempFile(t *testing.T, ext string, contents string) (string, error) {
9695

9796
fileName := f.Name()
9897

99-
if err := os.WriteFile(fileName, []byte(contents), 0644); err != nil {
98+
if err := os.WriteFile(fileName, []byte(contents), 0o644); err != nil {
10099
os.Remove(fileName)
101100
return "", fmt.Errorf("cannot write config to temp file %s, %v", fileName, err)
102101
}

cmd/nodeproblemdetector/node_problem_detector_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/spf13/pflag"
2626
"k8s.io/klog/v2"
27+
2728
"k8s.io/node-problem-detector/cmd/options"
2829
)
2930

cmd/options/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ package options
1919
import (
2020
"flag"
2121
"fmt"
22+
"net/url"
2223
"os"
2324
"time"
2425

25-
"net/url"
26-
2726
"github.com/spf13/pflag"
2827

2928
"k8s.io/node-problem-detector/pkg/exporters"

pkg/custompluginmonitor/custom_plugin_monitor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func init() {
3939
CustomPluginMonitorName,
4040
types.ProblemDaemonHandler{
4141
CreateProblemDaemonOrDie: NewCustomPluginMonitorOrDie,
42-
CmdOptionDescription: "Set to config file paths."})
42+
CmdOptionDescription: "Set to config file paths.",
43+
})
4344
}
4445

4546
type customPluginMonitor struct {

pkg/custompluginmonitor/plugin/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"time"
2828

2929
"k8s.io/klog/v2"
30+
3031
cpmtypes "k8s.io/node-problem-detector/pkg/custompluginmonitor/types"
3132
"k8s.io/node-problem-detector/pkg/util"
3233
"k8s.io/node-problem-detector/pkg/util/tomb"

pkg/custompluginmonitor/types/config_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ func TestCustomPluginConfigApplyConfiguration(t *testing.T) {
197197
},
198198
},
199199
"disable status update during initialization": {
200-
Orig: CustomPluginConfig{PluginGlobalConfig: pluginGlobalConfig{
201-
SkipInitialStatus: &disableInitialStatusUpdate,
202-
},
200+
Orig: CustomPluginConfig{
201+
PluginGlobalConfig: pluginGlobalConfig{
202+
SkipInitialStatus: &disableInitialStatusUpdate,
203+
},
203204
},
204205
Wanted: CustomPluginConfig{
205206
PluginGlobalConfig: pluginGlobalConfig{

pkg/exporters/k8sexporter/condition/manager.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ import (
2222
"sync"
2323
"time"
2424

25-
"k8s.io/node-problem-detector/pkg/exporters/k8sexporter/problemclient"
26-
"k8s.io/node-problem-detector/pkg/types"
27-
problemutil "k8s.io/node-problem-detector/pkg/util"
28-
2925
v1 "k8s.io/api/core/v1"
26+
"k8s.io/klog/v2"
3027
"k8s.io/utils/clock"
3128

32-
"k8s.io/klog/v2"
29+
"k8s.io/node-problem-detector/pkg/exporters/k8sexporter/problemclient"
30+
"k8s.io/node-problem-detector/pkg/types"
31+
problemutil "k8s.io/node-problem-detector/pkg/util"
3332
)
3433

3534
const (

0 commit comments

Comments
 (0)