mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -7,18 +7,18 @@ import (
|
|||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Process) Niceness(sc Syscaller) (int, error) {
|
func (*Process) Niceness(Syscaller) (int, error) {
|
||||||
return 0, errUnimplemented
|
return 0, errUnimplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) SetNiceness(sc Syscaller, score int) error {
|
func (*Process) SetNiceness(Syscaller, int) error {
|
||||||
return errUnimplemented
|
return errUnimplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) Cmd() string {
|
func (*Process) Cmd() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func List(fs afero.Fs, syscaller Syscaller) ([]*Process, error) {
|
func List(afero.Fs, Syscaller) ([]*Process, error) {
|
||||||
return nil, errUnimplemented
|
return nil, errUnimplemented
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ type Syscaller interface {
|
|||||||
Kill(pid int32, sig syscall.Signal) error
|
Kill(pid int32, sig syscall.Signal) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: unused // used on some but no all platforms
|
||||||
const defaultProcDir = "/proc"
|
const defaultProcDir = "/proc"
|
||||||
|
|
||||||
type Process struct {
|
type Process struct {
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ var errUnimplemented = xerrors.New("unimplemented")
|
|||||||
|
|
||||||
type nopSyscaller struct{}
|
type nopSyscaller struct{}
|
||||||
|
|
||||||
func (nopSyscaller) SetPriority(pid int32, priority int) error {
|
func (nopSyscaller) SetPriority(int32, int) error {
|
||||||
return errUnimplemented
|
return errUnimplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nopSyscaller) GetPriority(pid int32) (int, error) {
|
func (nopSyscaller) GetPriority(int32) (int, error) {
|
||||||
return 0, errUnimplemented
|
return 0, errUnimplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nopSyscaller) Kill(pid int32, sig syscall.Signal) error {
|
func (nopSyscaller) Kill(int32, syscall.Signal) error {
|
||||||
return errUnimplemented
|
return errUnimplemented
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"cdr.dev/slog"
|
|
||||||
"github.com/gliderlabs/ssh"
|
"github.com/gliderlabs/ssh"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
gossh "golang.org/x/crypto/ssh"
|
gossh "golang.org/x/crypto/ssh"
|
||||||
|
|
||||||
|
"cdr.dev/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// localForwardChannelData is copied from the ssh package.
|
// localForwardChannelData is copied from the ssh package.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package agentssh
|
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
|
// We are not worrying about other platforms at the moment because Gateway
|
||||||
// only supports Linux anyway.
|
// only supports Linux anyway.
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|||||||
+4
-1
@@ -44,8 +44,11 @@ type listeningPortsHandler struct {
|
|||||||
ignorePorts map[int]string
|
ignorePorts map[int]string
|
||||||
cacheDuration time.Duration
|
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
|
ports []codersdk.WorkspaceAgentListeningPort
|
||||||
|
//nolint: unused // used on some but not all platforms
|
||||||
mtime time.Time
|
mtime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package agent
|
|||||||
|
|
||||||
import "github.com/coder/coder/v2/codersdk"
|
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
|
// 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
|
// moment. The UI will not show any "no ports found" message to the user, so
|
||||||
// the user won't suspect a thing.
|
// the user won't suspect a thing.
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ import (
|
|||||||
func Get(username string) (string, error) {
|
func Get(username string) (string, error) {
|
||||||
// This command will output "UserShell: /bin/zsh" if successful, we
|
// This command will output "UserShell: /bin/zsh" if successful, we
|
||||||
// can ignore the error since we have fallback behavior.
|
// 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()
|
out, _ := exec.Command("dscl", ".", "-read", filepath.Join("/Users", username), "UserShell").Output()
|
||||||
s, ok := strings.CutPrefix(string(out), "UserShell: ")
|
s, ok := strings.CutPrefix(string(out), "UserShell: ")
|
||||||
if ok {
|
if ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user