Skip to content

Commit 914a6e7

Browse files
authored
Merge pull request #342 from pjsharath28/enable-revive-linter
Enable revive linter
2 parents 0fe9cd7 + 4f3aa22 commit 914a6e7

15 files changed

Lines changed: 31 additions & 30 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
uses: golangci/golangci-lint-action@v6
6767
with:
6868
version: v1.60.1
69-
args: --disable-all -v -E govet -E misspell -E gofmt -E ineffassign
69+
args: --disable-all -v -E govet -E misspell -E gofmt -E ineffassign -E revive
7070
apidiff:
7171
runs-on: ubuntu-latest
7272
if: github.base_ref

clock/testing/fake_clock.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,36 +268,36 @@ func (i *IntervalClock) Since(ts time.Time) time.Duration {
268268

269269
// After is unimplemented, will panic.
270270
// TODO: make interval clock use FakeClock so this can be implemented.
271-
func (*IntervalClock) After(d time.Duration) <-chan time.Time {
271+
func (*IntervalClock) After(_ time.Duration) <-chan time.Time {
272272
panic("IntervalClock doesn't implement After")
273273
}
274274

275275
// NewTimer is unimplemented, will panic.
276276
// TODO: make interval clock use FakeClock so this can be implemented.
277-
func (*IntervalClock) NewTimer(d time.Duration) clock.Timer {
277+
func (*IntervalClock) NewTimer(_ time.Duration) clock.Timer {
278278
panic("IntervalClock doesn't implement NewTimer")
279279
}
280280

281281
// AfterFunc is unimplemented, will panic.
282282
// TODO: make interval clock use FakeClock so this can be implemented.
283-
func (*IntervalClock) AfterFunc(d time.Duration, f func()) clock.Timer {
283+
func (*IntervalClock) AfterFunc(_ time.Duration, _ func()) clock.Timer {
284284
panic("IntervalClock doesn't implement AfterFunc")
285285
}
286286

287287
// Tick is unimplemented, will panic.
288288
// TODO: make interval clock use FakeClock so this can be implemented.
289-
func (*IntervalClock) Tick(d time.Duration) <-chan time.Time {
289+
func (*IntervalClock) Tick(_ time.Duration) <-chan time.Time {
290290
panic("IntervalClock doesn't implement Tick")
291291
}
292292

293293
// NewTicker has no implementation yet and is omitted.
294294
// TODO: make interval clock use FakeClock so this can be implemented.
295-
func (*IntervalClock) NewTicker(d time.Duration) clock.Ticker {
295+
func (*IntervalClock) NewTicker(_ time.Duration) clock.Ticker {
296296
panic("IntervalClock doesn't implement NewTicker")
297297
}
298298

299299
// Sleep is unimplemented, will panic.
300-
func (*IntervalClock) Sleep(d time.Duration) {
300+
func (*IntervalClock) Sleep(_ time.Duration) {
301301
panic("IntervalClock doesn't implement Sleep")
302302
}
303303

exec/exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestExecutableNotFound(t *testing.T) {
120120
}
121121
}
122122

123-
func TestStopBeforeStart(t *testing.T) {
123+
func TestStopBeforeStart(_ *testing.T) {
124124
cmd := New().Command("echo", "hello")
125125

126126
// no panic calling Stop before calling Run

exec/testing/fake_exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (fake *FakeExec) nextCommand(cmd string, args []string) exec.Cmd {
8686
}
8787

8888
// CommandContext wraps arguments into exec.Cmd
89-
func (fake *FakeExec) CommandContext(ctx context.Context, cmd string, args ...string) exec.Cmd {
89+
func (fake *FakeExec) CommandContext(_ context.Context, cmd string, args ...string) exec.Cmd {
9090
return fake.Command(cmd, args...)
9191
}
9292

exec/testing/fake_exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func getFakeExecWithScripts(exactOrder bool, disableScripts bool) *FakeExec {
130130
func makeFakeCmd(fakeCmd *FakeCmd, cmd string, args ...string) FakeCommandAction {
131131
c := cmd
132132
a := args
133-
return func(cmd string, args ...string) exec.Cmd {
133+
return func(_ string, _ ...string) exec.Cmd {
134134
command := InitFakeCmd(fakeCmd, c, a...)
135135
return command
136136
}

field/path.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func NewPath(name string, moreNames ...string) *Path {
4040

4141
// Root returns the root element of this Path.
4242
func (p *Path) Root() *Path {
43-
for ; p.parent != nil; p = p.parent {
44-
// Do nothing.
43+
for p.parent != nil {
44+
p = p.parent
4545
}
4646
return p
4747
}

lru/lru_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestRemove(t *testing.T) {
8888
}
8989
}
9090

91-
func TestGetRace(t *testing.T) {
91+
func TestGetRace(_ *testing.T) {
9292
// size to force eviction and exercise next,curr,prev list behavior
9393
lru := New(25)
9494

@@ -153,7 +153,7 @@ func TestSetEviction(t *testing.T) {
153153
t.Errorf("unexpected eviction data: key=%v val=%v", seenKey, seenVal)
154154
}
155155

156-
err = lru.SetEvictionFunc(func(key Key, value interface{}) {})
156+
err = lru.SetEvictionFunc(func(_ Key, _ interface{}) {})
157157
if err == nil {
158158
t.Errorf("expected error but got none")
159159
}

mount/mount.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type Interface interface {
7777
var _ Interface = &Mounter{}
7878

7979
// MountPoint represents a single line in /proc/mounts or /etc/fstab.
80-
type MountPoint struct { // nolint: golint
80+
type MountPoint struct { // nolint: revive
8181
Device string
8282
Path string
8383
Type string
@@ -86,7 +86,7 @@ type MountPoint struct { // nolint: golint
8686
Pass int
8787
}
8888

89-
type MountErrorType string // nolint: golint
89+
type MountErrorType string // nolint: revive
9090

9191
const (
9292
FilesystemMismatch MountErrorType = "FilesystemMismatch"
@@ -97,7 +97,7 @@ const (
9797
UnknownMountError MountErrorType = "UnknownMountError"
9898
)
9999

100-
type MountError struct { // nolint: golint
100+
type MountError struct { // nolint: revive
101101
Type MountErrorType
102102
Message string
103103
}

mount/mount_helper_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func IsCorruptedMnt(err error) bool {
5757
}
5858

5959
// MountInfo represents a single line in /proc/<pid>/mountinfo.
60-
type MountInfo struct { // nolint: golint
60+
type MountInfo struct { // nolint: revive
6161
// Unique ID for the mount (maybe reused after umount).
6262
ID int
6363
// The ID of the parent mount (or of self for the root of this mount namespace's mount tree).

mount/mount_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"syscall"
3030

3131
"k8s.io/klog/v2"
32+
3233
utilexec "k8s.io/utils/exec"
3334
utilio "k8s.io/utils/io"
3435
)
@@ -113,6 +114,9 @@ func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source stri
113114
mountCmd = mounterPath
114115
}
115116

117+
// If systemd-run is available, run mount in a transient scope.
118+
// Otherwise, assume kubelet is not running as a systemd service and
119+
// use the pre-populated mount command and arguments.
116120
if mounter.withSystemd {
117121
// Try to run mount via systemd-run --scope. This will escape the
118122
// service where kubelet runs and any fuse daemons will be started in a
@@ -137,10 +141,6 @@ func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source stri
137141
// systemd-mount is not used because it's too new for older distros
138142
// (CentOS 7, Debian Jessie).
139143
mountCmd, mountArgs, mountArgsLogStr = AddSystemdScopeSensitive("systemd-run", target, mountCmd, mountArgs, mountArgsLogStr)
140-
} else {
141-
// No systemd-run on the host (or we failed to check it), assume kubelet
142-
// does not run as a systemd service.
143-
// No code here, mountCmd and mountArgs are already populated.
144144
}
145145

146146
// Logging with sensitive mount options removed.

0 commit comments

Comments
 (0)