From 485e6c84e7ef783c126c392af072a974c9fb88ce Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 26 Jan 2022 19:13:15 -0800 Subject: [PATCH] Fix some revive warnings This is needed since the future commits will touch this code, and then the lint-extra CI job complains. > libcontainer/factory.go#L245 > var-naming: var fdsJson should be fdsJSON (revive) and > libcontainer/init_linux.go#L181 > error-strings: error strings should not be capitalized or end with punctuation or a newline (revive) and > notify_socket.go#L94 > receiver-naming: receiver name n should be consistent with previous receiver name s for notifySocket (revive) Signed-off-by: Kir Kolyshkin --- libcontainer/factory_linux.go | 6 +++--- libcontainer/init_linux.go | 2 +- notify_socket.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 9b74329ba..1ddc7a5db 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -400,14 +400,14 @@ func NewgidmapPath(newgidmapPath string) func(*LinuxFactory) error { } func parseMountFds() ([]int, error) { - fdsJson := os.Getenv("_LIBCONTAINER_MOUNT_FDS") - if fdsJson == "" { + fdsJSON := os.Getenv("_LIBCONTAINER_MOUNT_FDS") + if fdsJSON == "" { // Always return the nil slice if no fd is present. return nil, nil } var mountFds []int - if err := json.Unmarshal([]byte(fdsJson), &mountFds); err != nil { + if err := json.Unmarshal([]byte(fdsJSON), &mountFds); err != nil { return nil, fmt.Errorf("Error unmarshalling _LIBCONTAINER_MOUNT_FDS: %w", err) } diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 0734f42a0..8e8d3abd9 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -87,7 +87,7 @@ func newContainerInit(t initType, pipe *os.File, consoleSocket *os.File, fifoFd, case initSetns: // mountFds must be nil in this case. We don't mount while doing runc exec. if mountFds != nil { - return nil, errors.New("mountFds must be nil. Can't mount while doing runc exec.") + return nil, errors.New("mountFds must be nil; can't mount from exec") } return &linuxSetnsInit{ diff --git a/notify_socket.go b/notify_socket.go index 76aa27ca5..9dde506c3 100644 --- a/notify_socket.go +++ b/notify_socket.go @@ -91,12 +91,12 @@ func notifySocketStart(context *cli.Context, notifySocketHost, id string) (*noti return notifySocket, nil } -func (n *notifySocket) waitForContainer(container libcontainer.Container) error { - s, err := container.State() +func (s *notifySocket) waitForContainer(container libcontainer.Container) error { + state, err := container.State() if err != nil { return err } - return n.run(s.InitProcessPid) + return s.run(state.InitProcessPid) } func (n *notifySocket) run(pid1 int) error {