fix: appease linter on darwin (#11154)

Fixing up some linting errors that show up on Darwin, but not in CI.
This commit is contained in:
Spike Curtis 2023-12-12 17:02:28 +04:00 committed by GitHub
parent 2883cad6ad
commit edeb9bb42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 11 deletions

View File

@ -7,18 +7,18 @@ import (
"github.com/spf13/afero"
)
func (p *Process) Niceness(sc Syscaller) (int, error) {
func (*Process) Niceness(Syscaller) (int, error) {
return 0, errUnimplemented
}
func (p *Process) SetNiceness(sc Syscaller, score int) error {
func (*Process) SetNiceness(Syscaller, int) error {
return errUnimplemented
}
func (p *Process) Cmd() string {
func (*Process) Cmd() string {
return ""
}
func List(fs afero.Fs, syscaller Syscaller) ([]*Process, error) {
func List(afero.Fs, Syscaller) ([]*Process, error) {
return nil, errUnimplemented
}

View File

@ -10,6 +10,7 @@ type Syscaller interface {
Kill(pid int32, sig syscall.Signal) error
}
// nolint: unused // used on some but no all platforms
const defaultProcDir = "/proc"
type Process struct {

View File

@ -17,14 +17,14 @@ var errUnimplemented = xerrors.New("unimplemented")
type nopSyscaller struct{}
func (nopSyscaller) SetPriority(pid int32, priority int) error {
func (nopSyscaller) SetPriority(int32, int) error {
return errUnimplemented
}
func (nopSyscaller) GetPriority(pid int32) (int, error) {
func (nopSyscaller) GetPriority(int32) (int, error) {
return 0, errUnimplemented
}
func (nopSyscaller) Kill(pid int32, sig syscall.Signal) error {
func (nopSyscaller) Kill(int32, syscall.Signal) error {
return errUnimplemented
}

View File

@ -4,10 +4,11 @@ import (
"strings"
"sync"
"cdr.dev/slog"
"github.com/gliderlabs/ssh"
"go.uber.org/atomic"
gossh "golang.org/x/crypto/ssh"
"cdr.dev/slog"
)
// localForwardChannelData is copied from the ssh package.

View File

@ -2,7 +2,7 @@
package agentssh
func getListeningPortProcessCmdline(port uint32) (string, error) {
func getListeningPortProcessCmdline(uint32) (string, error) {
// We are not worrying about other platforms at the moment because Gateway
// only supports Linux anyway.
return "", nil

View File

@ -44,8 +44,11 @@ type listeningPortsHandler struct {
ignorePorts map[int]string
cacheDuration time.Duration
mut sync.Mutex
//nolint: unused // used on some but not all platforms
mut sync.Mutex
//nolint: unused // used on some but not all platforms
ports []codersdk.WorkspaceAgentListeningPort
//nolint: unused // used on some but not all platforms
mtime time.Time
}

View File

@ -4,7 +4,7 @@ package agent
import "github.com/coder/coder/v2/codersdk"
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
func (*listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
// moment. The UI will not show any "no ports found" message to the user, so
// the user won't suspect a thing.

View File

@ -13,6 +13,10 @@ import (
func Get(username string) (string, error) {
// This command will output "UserShell: /bin/zsh" if successful, we
// can ignore the error since we have fallback behavior.
if !filepath.IsLocal(username) {
return "", xerrors.Errorf("username is nonlocal path: %s", username)
}
//nolint: gosec // input checked above
out, _ := exec.Command("dscl", ".", "-read", filepath.Join("/Users", username), "UserShell").Output()
s, ok := strings.CutPrefix(string(out), "UserShell: ")
if ok {