Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 61fa5ad

Browse files
authored
feat: replace coder sh implementation to shell out to ssh (#292)
Previously, we used our custom WebSocket shell protocol to open shells with `coder sh`. This divergent behavior from genuine SSH creates confusion and lack of feature parity between the two connection methods.
1 parent ff7ba37 commit 61fa5ad

File tree

9 files changed

+154
-533
lines changed

9 files changed

+154
-533
lines changed

docs/coder.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ coder provides a CLI for working with an existing Coder Enterprise installation
1717
* [coder images](coder_images.md) - Manage Coder images
1818
* [coder login](coder_login.md) - Authenticate this client for future operations
1919
* [coder logout](coder_logout.md) - Remove local authentication credentials if any exist
20-
* [coder sh](coder_sh.md) - Open a shell and execute commands in a Coder environment
20+
* [coder ssh](coder_ssh.md) - Enter a shell of execute a command over SSH into a Coder environment
2121
* [coder sync](coder_sync.md) - Establish a one way directory sync to a Coder environment
2222
* [coder tokens](coder_tokens.md) - manage Coder API tokens for the active user
2323
* [coder urls](coder_urls.md) - Interact with environment DevURLs

docs/coder_sh.md

-37
This file was deleted.

docs/coder_ssh.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## coder ssh
2+
3+
Enter a shell of execute a command over SSH into a Coder environment
4+
5+
```
6+
coder ssh [environment_name] [<command [args...]>]
7+
```
8+
9+
### Examples
10+
11+
```
12+
coder ssh my-dev
13+
coder ssh my-dev pwd
14+
```
15+
16+
### Options
17+
18+
```
19+
-h, --help help for ssh
20+
```
21+
22+
### Options inherited from parent commands
23+
24+
```
25+
-v, --verbose show verbose output
26+
```
27+
28+
### SEE ALSO
29+
30+
* [coder](coder.md) - coder provides a CLI for working with an existing Coder Enterprise installation
31+

internal/cmd/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func Make() *cobra.Command {
2424
app.AddCommand(
2525
loginCmd(),
2626
logoutCmd(),
27-
shCmd(),
27+
sshCmd(),
2828
usersCmd(),
2929
tagsCmd(),
3030
configSSHCmd(),

internal/cmd/configssh.go

-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
"cdr.dev/coder-cli/coder-sdk"
2020
"cdr.dev/coder-cli/internal/coderutil"
21-
"cdr.dev/coder-cli/internal/config"
2221
)
2322

2423
const sshStartToken = "# ------------START-CODER-ENTERPRISE-----------"
@@ -214,19 +213,6 @@ func makeSSHConfig(host, userName, envName, privateKeyFilepath string) string {
214213
`, envName, host, userName, envName, privateKeyFilepath)
215214
}
216215

217-
//nolint:deadcode,unused
218-
func configuredHostname() (string, error) {
219-
u, err := config.URL.Read()
220-
if err != nil {
221-
return "", err
222-
}
223-
url, err := url.Parse(u)
224-
if err != nil {
225-
return "", err
226-
}
227-
return url.Hostname(), nil
228-
}
229-
230216
func writeStr(filename, data string) error {
231217
return ioutil.WriteFile(filename, []byte(data), 0777)
232218
}

0 commit comments

Comments
 (0)