Commit graph

84 commits

Author SHA1 Message Date
Caleb Brose
55bce59ab7
Add command to open codespaces in JupyterLab
Add command to open codespaces in JupyterLab
2022-04-28 16:11:14 -05:00
JP Ungaretti
ceba2c896b Use safeClose instead of Close 2022-04-28 18:38:46 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
JP Ungaretti
3216d1bb3a Remove function return 2022-04-21 14:29:30 -07:00
JP Ungaretti
4452f37819 Clarify session helper 2022-04-14 17:10:11 -05:00
JP Ungaretti
eaf8f84baf Merge branch 'trunk' into add-cs-jupyter 2022-04-14 15:27:40 -05:00
Mislav Marohnić
3f5311ea1c
Merge pull request #5345 from znull/znull/ssh-config-example
ssh.go: use setup example that should work with any ssh config
2022-03-29 16:15:56 +02:00
Jason Lunz
17cb6346a5
ssh.go: use setup example that should work with any ssh config
The `gh cs ssh` command suggests an example recipe for setting up
openssh integration. The last step appends an `Include` statement to the
user's `~/.ssh/config`.

Unfortunately, this won't always work as intended. If the existing
configuration ends with a `Host` block, the added `Include` statement
will be conditional on whether that block matches.

By preceding the `Include` statement with `Match all`, we can ensure
that it is always evaluated.
2022-03-23 17:00:36 -06:00
Caleb Brose
623e67f6b1 Update comments/usage and remove -- 2022-03-23 16:09:07 +00:00
Caleb Brose
f22320a478 Parse scp args 2022-03-22 01:57:37 +00:00
Steve Gray
b48a93cddf
Remove unwanted trailing quote
Removes a stray quote from the codespace ssh example.
2022-03-18 14:06:27 -06:00
Charlie Andrews
64eecef176 Remove unhelpful error wrapper 2022-03-16 09:36:14 -04:00
Charlie Andrews
8bf0cb8f13 Refactor the getOrChooseCodespace to always check for pending ops 2022-03-16 08:56:17 -04:00
Charlie Andrews
afa71c4b2f Disallow ssh'ing to codespace with a pending operation
Since the API already disallows this, this makes the error cleaner and
more explicit when a user is trying to start/ssh into a codespace that
has a pending operation.

Example of the old error message:

```
$ gh cs ssh -c cwndrws-redacted
Starting codespace ⣽error connecting to codespace: error starting codespace: HTTP 422: your codespace has an operation pending: updating to a sku with a different amount of storage; please wait until this operation is complete (https://api.github.com/user/codespaces/cwndrws-redacted/start)
exit status 1

```

Example of the new error message:

```
$ gh cs ssh -c cwndrws-redacted
codespace is disabled while it has a pending operation: Changing machine types...
exit status 1
```
2022-03-15 17:21:28 -04:00
GitHub Action
21a1059f7c Add --profile option to gh cs cp 2022-03-10 19:01:55 -06:00
JP Ungaretti
fba5fb4eec Refactor liveshare setup to a new function 2022-03-04 00:54:15 +00:00
Jason Lunz
61e5fbb007
Revert "move gh cs ssh --config into a separate gh cs ssh config command"
This reverts commit c9d0085e57.
2022-01-06 10:03:54 -07:00
Mislav Marohnić
3b7e5fc246 Store Executable() information on codespaces App
This is to avoid having to explicitly pass it to each subcommand that
needs it. Each codespaces command runs in the context of App, so that's
a point of shared context that we can store state in.
2021-12-21 14:03:10 +01:00
Jason Lunz
38eb894d73
prevent leaking any blocked goroutines on error 2021-12-20 13:57:53 -07:00
Jason Lunz
932c9da473
clean up inadvertently truncated help message 2021-12-20 13:57:53 -07:00
Jason Lunz
7bd6fe9af8
maximize the time checkAuthorizedKeys has to run concurrently
Also, other than that, restore the original ordering of this function
2021-12-20 13:57:53 -07:00
Jason Lunz
a864985f0a
use WaitGroup for a more idiomatic concurrency pattern 2021-12-20 13:57:53 -07:00
Jason Lunz
81b34d272c
inline openSSHSession 2021-12-20 13:57:53 -07:00
Jason Lunz
28dd73ffdf
always pass a non-nil logger to openSSHSession 2021-12-20 13:57:53 -07:00
Jason Lunz
37f8039f76
merge ensureAuthorizedKeys into checkAuthorizedKeys 2021-12-20 13:57:52 -07:00
Jason Lunz
ae3aacb964
fix errcheck linter warning 2021-12-20 13:57:52 -07:00
Jason Lunz
6b34fa2a27
oh look, struct definitions can be scoped! 2021-12-20 13:57:52 -07:00
Jason Lunz
f22be4a03d
use a more robust method to get the executable path
cmdutil.Factory.Executable() accounts for things like package managers
and symlinks to the actual executable.

An alternative to passing the *cmdutil.Factory down the stack would be
stashing the executable string in the codespace.App, which works (and
the diff is smaller), but it produced some odd non-local test failures.
This way seems less mysterious and more like other uses of Factory in
the codebase.
2021-12-20 13:57:52 -07:00
Jason Lunz
7b432de5c2
use heredoc helper for config template 2021-12-17 17:09:06 -07:00
Jason Lunz
b2598d64f9
start codespace to fetch config if it's explicitly requested
When running `gh cs ssh config` without a `-c` option, we skip
codespaces that aren't available. This change suppresses that behavior
when a single codespace is explicitly requested, starting the codespace
if it's not running.
2021-12-17 17:08:58 -07:00
Jason Lunz
61823997c2
always verify authorized keys in parallel with other work, and at most once 2021-12-17 16:46:53 -07:00
Jason Lunz
0af268da4e
properly indent ssh config example 2021-12-17 16:11:55 -07:00
Jason Lunz
06eb5ad47f
fetch remote ssh usernames in parallel 2021-12-17 16:10:44 -07:00
Jason Lunz
2ee88da647
close session on error 2021-12-17 14:42:54 -07:00
Jason Lunz
a05541f4ed
drop redundant API call 2021-12-17 11:39:14 -07:00
Jason Lunz
0670a7758b
use generic io interfaces 2021-12-17 11:18:59 -07:00
Jason Lunz
811d6505d2
tighten up ssh config help wording 2021-12-17 11:03:11 -07:00
Jason Lunz
206b6379c3
return non-zero if ssh config skips any codespaces 2021-12-17 10:47:22 -07:00
Jason Lunz
a9d02a746b
push fetching codespace details into openSSHSession callers 2021-12-16 17:19:34 -07:00
Jason Lunz
ac685611b1
openssh -> OpenSSH 2021-12-16 17:00:40 -07:00
Jason Lunz
71c9fa11f0
add more ssh config --help documentation 2021-12-16 17:00:40 -07:00
Jason Lunz
369ea534b6
explain why failure to connect to a codespace doesn't fail the entire command 2021-12-16 17:00:39 -07:00
Jason Lunz
4a6887f99e
add a comment explaining why we build an sshUsers map 2021-12-16 17:00:38 -07:00
Jason Lunz
6f8635a17e
listOpensshConfig -> printOpenSSHConfig 2021-12-16 17:00:37 -07:00
Jason Lunz
b7cd2bbc72
no need to separately declare vars here 2021-12-16 17:00:37 -07:00
Jason Lunz
3cb3cf7ca5
make ListOpensshConfig private 2021-12-16 17:00:36 -07:00
Jason Lunz
96a2e125e6
document the codespaceSSHConfig struct 2021-12-16 17:00:36 -07:00
Jason Lunz
ca3b59dd35
use struct embedding to express this less verbosely 2021-12-16 16:09:33 -07:00
Jason Lunz
ac3b0c50e3
Ssh -> SSH 2021-12-16 16:09:32 -07:00
Jason Lunz
92609bd1ec
Revert "use go-multierror to combine read/write close errors"
This reverts commit 456f4381e02aa843ddb3cc1b9628cb81487ba895.
2021-12-16 16:09:32 -07:00