Skip to content

Commit

Permalink
*: fix golangci-lint issue
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <[email protected]>
  • Loading branch information
fuweid committed Dec 28, 2023
1 parent 6fdf2c1 commit 56849a7
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 64 deletions.
5 changes: 1 addition & 4 deletions cmd/embedshim-runcext/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func newApp() *cli.App {
}
app.Commands = append(app.Commands, execCommand)
app.Before = func(_ *cli.Context) error {
if err := reaper.SetSubreaper(1); err != nil {
return err
}
return nil
return reaper.SetSubreaper(1)
}
return app
}
Expand Down
22 changes: 11 additions & 11 deletions delete_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@ import (
type deletedState struct {
}

func (s *deletedState) Pause(ctx context.Context) error {
func (s *deletedState) Pause(_ context.Context) error {
return fmt.Errorf("cannot pause a deleted process")
}

func (s *deletedState) Resume(ctx context.Context) error {
func (s *deletedState) Resume(_ context.Context) error {
return fmt.Errorf("cannot resume a deleted process")
}

func (s *deletedState) Update(context context.Context, r *google_protobuf.Any) error {
func (s *deletedState) Update(_ context.Context, _ *google_protobuf.Any) error {
return fmt.Errorf("cannot update a deleted process")
}

func (s *deletedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (s *deletedState) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("cannot checkpoint a deleted process")
}

func (s *deletedState) Resize(ws console.WinSize) error {
func (s *deletedState) Resize(_ console.WinSize) error {
return fmt.Errorf("cannot resize a deleted process")
}

func (s *deletedState) Start(ctx context.Context) error {
func (s *deletedState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a deleted process")
}

func (s *deletedState) Delete(ctx context.Context) error {
func (s *deletedState) Delete(_ context.Context) error {
return fmt.Errorf("cannot delete a deleted process: %w", errdefs.ErrNotFound)
}

func (s *deletedState) Kill(ctx context.Context, sig uint32, all bool) error {
func (s *deletedState) Kill(_ context.Context, _ uint32, _ bool) error {
return fmt.Errorf("cannot kill a deleted process: %w", errdefs.ErrNotFound)
}

func (s *deletedState) SetExited(status int) {
func (s *deletedState) SetExited(_ int) {
// no op
}

func (s *deletedState) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.Process, error) {
func (s *deletedState) Exec(_ context.Context, _ string, _ runtime.ExecOpts) (runtime.Process, error) {
return nil, fmt.Errorf("cannot exec in a deleted state")
}

func (s *deletedState) Status(ctx context.Context) (string, error) {
func (s *deletedState) Status(_ context.Context) (string, error) {
return "stopped", nil
}
4 changes: 2 additions & 2 deletions exec_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (e *execProcess) setExited(status int) {
close(e.waitBlock)
}

func (e *execProcess) CloseIO(ctx context.Context) error {
func (e *execProcess) CloseIO(_ context.Context) error {
if stdin := e.Stdin(); stdin != nil {
if err := stdin.Close(); err != nil {
return err
Expand Down Expand Up @@ -214,7 +214,7 @@ func (e *execProcess) Kill(ctx context.Context, sig uint32, _ bool) error {
return e.execState.Kill(ctx, sig, false)
}

func (e *execProcess) kill(ctx context.Context, sig uint32, _ bool) error {
func (e *execProcess) kill(_ context.Context, sig uint32, _ bool) error {
pid := e.pid.get()
switch {
case pid == 0:
Expand Down
16 changes: 8 additions & 8 deletions exec_process_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *execCreatedState) SetExited(status int) {
}
}

func (s *execCreatedState) Status(ctx context.Context) (string, error) {
func (s *execCreatedState) Status(_ context.Context) (string, error) {
return "created", nil
}

Expand All @@ -104,11 +104,11 @@ func (s *execRunningState) Resize(ws console.WinSize) error {
return s.p.resize(ws)
}

func (s *execRunningState) Start(ctx context.Context) error {
func (s *execRunningState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a running process")
}

func (s *execRunningState) Delete(ctx context.Context) error {
func (s *execRunningState) Delete(_ context.Context) error {
return fmt.Errorf("cannot delete a running process")
}

Expand All @@ -124,7 +124,7 @@ func (s *execRunningState) SetExited(status int) {
}
}

func (s *execRunningState) Status(ctx context.Context) (string, error) {
func (s *execRunningState) Status(_ context.Context) (string, error) {
return "running", nil
}

Expand All @@ -142,11 +142,11 @@ func (s *execStoppedState) transition(name string) error {
return nil
}

func (s *execStoppedState) Resize(ws console.WinSize) error {
func (s *execStoppedState) Resize(_ console.WinSize) error {
return fmt.Errorf("cannot resize a stopped container")
}

func (s *execStoppedState) Start(ctx context.Context) error {
func (s *execStoppedState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a stopped process")
}

Expand All @@ -162,10 +162,10 @@ func (s *execStoppedState) Kill(ctx context.Context, sig uint32, all bool) error
return s.p.kill(ctx, sig, all)
}

func (s *execStoppedState) SetExited(status int) {
func (s *execStoppedState) SetExited(_ int) {
// no op
}

func (s *execStoppedState) Status(ctx context.Context) (string, error) {
func (s *execStoppedState) Status(_ context.Context) (string, error) {
return "stopped", nil
}
2 changes: 1 addition & 1 deletion init_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (p *initProcess) exec(ctx context.Context, execID string, opts runtime.Exec
}

// Checkpoint the init process
func (p *initProcess) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (p *initProcess) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("checkpoint not implemented yet")
}

Expand Down
50 changes: 25 additions & 25 deletions init_process_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ func (s *createdState) transition(name string) error {
return nil
}

func (s *createdState) Pause(ctx context.Context) error {
func (s *createdState) Pause(_ context.Context) error {
return fmt.Errorf("cannot pause task in created state")
}

func (s *createdState) Resume(ctx context.Context) error {
func (s *createdState) Resume(_ context.Context) error {
return fmt.Errorf("cannot resume task in created state")
}

func (s *createdState) Update(ctx context.Context, r *google_protobuf.Any) error {
return s.p.update(ctx, r)
}

func (s *createdState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (s *createdState) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("cannot checkpoint a task in created state")
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *createdState) Exec(ctx context.Context, id string, opts runtime.ExecOpt
return s.p.exec(ctx, id, opts)
}

func (s *createdState) Status(ctx context.Context) (string, error) {
func (s *createdState) Status(_ context.Context) (string, error) {
return "created", nil
}

Expand All @@ -135,27 +135,27 @@ func (s *runningState) transition(name string) error {
return nil
}

func (s *runningState) Pause(ctx context.Context) error {
func (s *runningState) Pause(_ context.Context) error {
return fmt.Errorf("pause not implemented yet")
}

func (s *runningState) Resume(ctx context.Context) error {
func (s *runningState) Resume(_ context.Context) error {
return fmt.Errorf("cannot resume a running process")
}

func (s *runningState) Update(ctx context.Context, r *google_protobuf.Any) error {
return s.p.update(ctx, r)
}

func (s *runningState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (s *runningState) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("checkpoint not implemented yet")
}

func (s *runningState) Start(ctx context.Context) error {
func (s *runningState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a running process")
}

func (s *runningState) Delete(ctx context.Context) error {
func (s *runningState) Delete(_ context.Context) error {
return fmt.Errorf("cannot delete a running process")
}

Expand All @@ -175,7 +175,7 @@ func (s *runningState) Exec(ctx context.Context, id string, opts runtime.ExecOpt
return s.p.exec(ctx, id, opts)
}

func (s *runningState) Status(ctx context.Context) (string, error) {
func (s *runningState) Status(_ context.Context) (string, error) {
return "running", nil
}

Expand All @@ -195,27 +195,27 @@ func (s *pausedState) transition(name string) error {
return nil
}

func (s *pausedState) Pause(ctx context.Context) error {
func (s *pausedState) Pause(_ context.Context) error {
return fmt.Errorf("cannot pause a paused container")
}

func (s *pausedState) Resume(ctx context.Context) error {
func (s *pausedState) Resume(_ context.Context) error {
return fmt.Errorf("resume not implemented yet")
}

func (s *pausedState) Update(ctx context.Context, r *google_protobuf.Any) error {
return s.p.update(ctx, r)
}

func (s *pausedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (s *pausedState) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("checkpoint not implemented yet")
}

func (s *pausedState) Start(ctx context.Context) error {
func (s *pausedState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a paused process")
}

func (s *pausedState) Delete(ctx context.Context) error {
func (s *pausedState) Delete(_ context.Context) error {
return fmt.Errorf("cannot delete a paused process")
}

Expand All @@ -235,11 +235,11 @@ func (s *pausedState) SetExited(status int) {
}
}

func (s *pausedState) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.Process, error) {
func (s *pausedState) Exec(_ context.Context, _ string, _ runtime.ExecOpts) (runtime.Process, error) {
return nil, fmt.Errorf("cannot exec in a paused state")
}

func (s *pausedState) Status(ctx context.Context) (string, error) {
func (s *pausedState) Status(_ context.Context) (string, error) {
return "paused", nil
}

Expand All @@ -257,23 +257,23 @@ func (s *stoppedState) transition(name string) error {
return nil
}

func (s *stoppedState) Pause(ctx context.Context) error {
func (s *stoppedState) Pause(_ context.Context) error {
return fmt.Errorf("cannot pause a stopped container")
}

func (s *stoppedState) Resume(ctx context.Context) error {
func (s *stoppedState) Resume(_ context.Context) error {
return fmt.Errorf("cannot resume a stopped container")
}

func (s *stoppedState) Update(ctx context.Context, r *google_protobuf.Any) error {
func (s *stoppedState) Update(_ context.Context, _ *google_protobuf.Any) error {
return fmt.Errorf("cannot update a stopped container")
}

func (s *stoppedState) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
func (s *stoppedState) Checkpoint(_ context.Context, _ *CheckpointConfig) error {
return fmt.Errorf("cannot checkpoint a stopped container")
}

func (s *stoppedState) Start(ctx context.Context) error {
func (s *stoppedState) Start(_ context.Context) error {
return fmt.Errorf("cannot start a stopped process")
}

Expand All @@ -288,15 +288,15 @@ func (s *stoppedState) Kill(ctx context.Context, sig uint32, all bool) error {
return s.p.kill(ctx, sig, all)
}

func (s *stoppedState) SetExited(status int) {
func (s *stoppedState) SetExited(_ int) {
// no op
}

func (s *stoppedState) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.Process, error) {
func (s *stoppedState) Exec(_ context.Context, _ string, _ runtime.ExecOpts) (runtime.Process, error) {
return nil, fmt.Errorf("cannot exec in a stopped state")
}

func (s *stoppedState) Status(ctx context.Context) (string, error) {
func (s *stoppedState) Status(_ context.Context) (string, error) {
return "stopped", nil
}

Expand Down
4 changes: 2 additions & 2 deletions io.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (p *processIO) CopyStdin() error {
return nil
}

func createIO(ctx context.Context, id string, ioUID, ioGID int, stdio stdio.Stdio) (*processIO, error) {
func createIO(_ context.Context, _ string, ioUID, ioGID int, stdio stdio.Stdio) (*processIO, error) {
pio := &processIO{
stdio: stdio,
}
Expand Down Expand Up @@ -289,7 +289,7 @@ func withConditionalIO(c stdio.Stdio) runc.IOOpt {
}
}

func openRWFifo(ctx context.Context, fn string, perm os.FileMode) (*os.File, error) {
func openRWFifo(_ context.Context, fn string, perm os.FileMode) (*os.File, error) {
if _, err := os.Stat(fn); err != nil {
if os.IsNotExist(err) {
if err := syscall.Mkfifo(fn, uint32(perm&os.ModePerm)); err != nil && !os.IsExist(err) {
Expand Down
4 changes: 2 additions & 2 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type linuxPlatform struct {
epoller *console.Epoller
}

func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console, id, stdin, stdout, stderr string, wg *sync.WaitGroup) (cons console.Console, retErr error) {
func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console, _, stdin, stdout, _ string, wg *sync.WaitGroup) (cons console.Console, retErr error) {
if p.epoller == nil {
return nil, fmt.Errorf("uninitialized epoller")
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console
return epollConsole, nil
}

func (p *linuxPlatform) ShutdownConsole(ctx context.Context, cons console.Console) error {
func (p *linuxPlatform) ShutdownConsole(_ context.Context, cons console.Console) error {
if p.epoller == nil {
return fmt.Errorf("uninitialized epoller")
}
Expand Down
2 changes: 1 addition & 1 deletion reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (manager *TaskManager) loadTasks(ctx context.Context) error {
return nil
}

func (manager *TaskManager) loadShim(ctx context.Context, bundle *pkgbundle.Bundle) (_ *shim, retErr error) {
func (manager *TaskManager) loadShim(_ context.Context, bundle *pkgbundle.Bundle) (_ *shim, retErr error) {
init, err := renewInitProcess(bundle)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 56849a7

Please sign in to comment.