Skip to content

Commit 0224426

Browse files
authored
refactor(agent): Move SSH server into agentssh package (#7004)
Refs: #6177
1 parent 3ff2ae1 commit 0224426

File tree

9 files changed

+908
-548
lines changed

9 files changed

+908
-548
lines changed

agent/agent.go

+32-536
Large diffs are not rendered by default.

agent/agent_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"cdr.dev/slog"
4242
"cdr.dev/slog/sloggers/slogtest"
4343
"github.com/coder/coder/agent"
44+
"github.com/coder/coder/agent/agentssh"
4445
"github.com/coder/coder/coderd/httpapi"
4546
"github.com/coder/coder/codersdk"
4647
"github.com/coder/coder/codersdk/agentsdk"
@@ -131,13 +132,13 @@ func TestAgent_Stats_Magic(t *testing.T) {
131132
defer sshClient.Close()
132133
session, err := sshClient.NewSession()
133134
require.NoError(t, err)
134-
session.Setenv(agent.MagicSSHSessionTypeEnvironmentVariable, agent.MagicSSHSessionTypeVSCode)
135+
session.Setenv(agentssh.MagicSessionTypeEnvironmentVariable, agentssh.MagicSessionTypeVSCode)
135136
defer session.Close()
136137

137-
command := "sh -c 'echo $" + agent.MagicSSHSessionTypeEnvironmentVariable + "'"
138+
command := "sh -c 'echo $" + agentssh.MagicSessionTypeEnvironmentVariable + "'"
138139
expected := ""
139140
if runtime.GOOS == "windows" {
140-
expected = "%" + agent.MagicSSHSessionTypeEnvironmentVariable + "%"
141+
expected = "%" + agentssh.MagicSessionTypeEnvironmentVariable + "%"
141142
command = "cmd.exe /c echo " + expected
142143
}
143144
output, err := session.Output(command)
@@ -158,7 +159,7 @@ func TestAgent_Stats_Magic(t *testing.T) {
158159
defer sshClient.Close()
159160
session, err := sshClient.NewSession()
160161
require.NoError(t, err)
161-
session.Setenv(agent.MagicSSHSessionTypeEnvironmentVariable, agent.MagicSSHSessionTypeVSCode)
162+
session.Setenv(agentssh.MagicSessionTypeEnvironmentVariable, agentssh.MagicSessionTypeVSCode)
162163
defer session.Close()
163164
stdin, err := session.StdinPipe()
164165
require.NoError(t, err)
@@ -1651,7 +1652,7 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
16511652
}
16521653
waitGroup.Add(1)
16531654
go func() {
1654-
agent.Bicopy(context.Background(), conn, ssh)
1655+
agentssh.Bicopy(context.Background(), conn, ssh)
16551656
waitGroup.Done()
16561657
}()
16571658
}

0 commit comments

Comments
 (0)