Commit Graph

171 Commits

Author SHA1 Message Date
Steven Masley 5137433123
chore: add validation errors to the cli output (#12814)
* chore: add validation errors to the cli output
2024-04-02 10:02:30 -05:00
elasticspoon cfb94284e0
feat(cli): add golden tests for errors (#11588) (#12698)
* feat(cli): add golden tests for errors (#11588)

Creates golden files from `coder/cli/errors.go`.
Adds a unit test to test against golden files.
Adds a make file command to regenerate golden files.
Abstracts test against golden files.
2024-04-01 09:19:26 -05:00
Kyle Carberry 03ab37b343
chore: remove middleware to request version and entitlement warnings (#12750)
This cleans up `root.go` a bit, adds tests for middleware HTTP transport
functions, and removes two HTTP requests we always always performed previously
when executing *any* client command.

It should improve CLI performance (especially for users with higher latency).
2024-03-25 15:01:42 -04:00
Ammar Bandukwala 0d86dca852
fix(codersdk): abort in-progress writes/reads when closing websocket (#12650)
Fixes #9203

Related #12065

Also, adds some basic tracing infrastructure that we can build upon for more improvements.
2024-03-20 11:53:32 -05:00
Ammar Bandukwala e5cc17af92
chore(cli): hide --organization (#12626)
It's potentially confusing to users since we aren't fleshing out organizations right now.
2024-03-18 09:09:26 -05:00
elasticspoon 5011edc292
fix(cli): show error/hide help for unsupported subcommands (#10760) (#12624)
Fixes #10760 

The coder CLI quietly accepts any subcommand arguments and silently swallows them.

Currently:
```sh
❯ coder | head -n5
coder v2.3.3+e491217

USAGE:
  coder [global-flags] <subcommand>
```

```sh
❯ coder idontexist | head -n5
coder v2.3.3+e491217

USAGE:
  coder [global-flags] <subcommand>
```

Now help output will not be show when there is an unknown subcommand error. Instead users will be given the command for the help output.

```sh
❯ coder idontexist
Encountered an error running "coder", see "coder --help" for more information 
error: unrecognized subcommand "idontexist"
```
```sh
❯ coder iexistbut idontexist
Encountered an error running "coder iexistbut", see "coder iexistbut --help" for more information 
error: unrecognized subcommand "idontexist"
```

Also this stuff: `Encountered an error running "coder iexistbut"... ` gets written to `os.Stdout` in `prettyErrorFormatter{w: os.Stderr, verbose: r.verbose}`, not sure how to test that output.
2024-03-17 22:17:43 -05:00
Ammar Bandukwala b4c0fa80d8
chore(cli): rename Cmd to Command (#12616)
I think Command is cleaner and my original decision to use "Cmd"
a mistake.

Plus this creates better parity with cobra.
2024-03-17 09:45:26 -05:00
Ammar Bandukwala 496232446d
chore(cli): replace clibase with external `coder/serpent` (#12252) 2024-03-15 11:24:38 -05:00
Steven Masley 29c8cf20e0
fix: handle CLI default organization when none exists in <v2.9.0 coderd (#12594)
* chore: 'coder org set' help message was incorrect
* fix: handler coder cli against older versions of Coder
2024-03-14 15:11:29 -05:00
elasticspoon 773862a9f5
feat(cli): make url optional for login command (#10925) (#12466)
Allow `coder login` to log into existing deployment if available.

Update help and error messages to indicate that `coder login` is
available as a command.

Fixes #10925
Fixes #9551
2024-03-11 16:14:19 +02:00
Mathias Fredriksson 4ce1448bbe
fix(cli): generate correctly named file in DumpHandler (#12409) 2024-03-04 18:35:33 +02:00
Cian Johnston b1c2fea78b
feat(cli): add support cmd (#12328)
Part of #12163

- Adds a command coder support bundle <workspace> that generates a 
  support bundle and writes it to coder-support-$(date +%s).zip.
- Note: this is hidden currently until the rest of the functionality is fleshed out.
2024-03-01 17:13:50 +00:00
Cian Johnston 9f3591add8
chore(cli): use xerrors.Errorf instead of fmt.Errorf (#12368) 2024-02-29 18:58:48 +00:00
Steven Masley 70ccefc357
feat: set organization context in coder organizations (#12265)
* feat: add coder organizations set to change org context

`coder organizations set <org>`
2024-02-26 11:39:26 -06:00
Steven Masley 748cf4b2c4
feat: implement global flag for org selection (#12276)
* feat: implement global flag for org selection

Any command can use '-z' to override org context
2024-02-26 11:38:49 -06:00
Steven Masley d2998c6b7b
feat: implement organization context in the cli (#12259)
* feat: implement organization context in the cli

`coder org show current`
2024-02-26 10:03:49 -06:00
Jon Ayers 0c30dde9b5
feat: add customizable upgrade message on client/server version mismatch (#11587) 2024-01-30 17:11:37 -06:00
Cian Johnston 70dc282b7d
feat(cli): add favorite/unfavorite commands (#11793) 2024-01-24 14:05:39 +00:00
Steven Masley f5a9f5ca3d
chore: handle errors in wsproxy server for cli using buildinfo (#11584)
Cli errors are pretty formatted. This handles nested pretty types. Before it found the first error it could understand and return that. Now it will print the full error stack with more information.

To prevent information loss, a "[Trace=...]" was added to capture some extra error context for debugging.
2024-01-11 16:55:34 -06:00
Mathias Fredriksson df3c310379
feat(cli): add `coder open vscode` (#11191)
Fixes #7667
2024-01-02 20:46:18 +02:00
Spike Curtis 52b87a28b0
fix: stop printing warnings on external provisioner daemon command (#11309)
fixes #11307
2023-12-21 16:55:34 +04:00
Dean Sheather 695f57f7ff
fix: use header flags in wsproxy server (#10985) 2023-12-05 14:13:42 +04:00
Mathias Fredriksson 61be4dfe5a
fix: improve exit codes for agent/agentssh and cli/ssh (#10850) 2023-11-24 14:35:56 +02:00
Spike Curtis 4894eda711
feat: capture cli logs in tests (#10669)
Adds a Logger to cli Invocation and standardizes CLI commands to use it.  clitest creates a test logger by default so that CLI command logs are captured in the test logs.

CLI commands that do their own log configuration are modified to add sinks to the existing logger, rather than create a new one.  This ensures we still capture logs in CLI tests.
2023-11-14 22:56:27 +04:00
Jon Ayers 2dce4151ba
feat: add cli support for workspace automatic updates (#10438) 2023-11-02 14:41:34 -05:00
Jon Ayers 05a393cd06
feat: only display license warnings to privileged users (#10096) 2023-10-10 12:48:51 -05:00
Kyle Carberry 35538e1051
feat: add `external-auth` cli (#10052)
* feat: add `external-auth` cli

* Add subcommands

* Improve descriptions

* Add external-auth subcommand

* Fix docs

* Fix gen

* Fix comment

* Fix golden file
2023-10-09 23:04:35 +00:00
Kyle Carberry ad47ef17e8
feat: allow reading the agent token from a file (#10080)
Adds `CODER_AGENT_TOKEN_FILE` which will read the agent token from
a file if `CODER_AGENT_TOKEN` is not provided. Using a Kubernetes
Secret with a volume-mounted file is a more secure way to provide
the agent token instead of an environment variable.
2023-10-05 15:41:05 -05:00
Kyle Carberry bca7416069
fix: add `--version` flag to the root to support migrating customers (#10063) 2023-10-04 15:37:15 -05:00
Steven Masley e9ccb8dc78
chore: change cli error message handling (#9952)
* chore: add command to easily visualize different errors

* chore: add verbose error printing in cli
2023-09-29 16:50:23 -05:00
Cian Johnston fad02081fc
fix: avoid logging env in unit tests (#9885) 2023-09-27 13:34:40 +01:00
Colin Adler 38560dd922
chore: remove coder trace telemetry (#9677) 2023-09-14 02:20:28 -04:00
Ammar Bandukwala dd97fe2bce
chore(cli): replace lipgloss with coder/pretty (#9564)
This change will improve over CLI performance and "snappiness" as well as
substantially reduce our test times. Preliminary benchmarks show
`coder server --help` times cut from 300ms to 120ms on my dogfood
instance.

The inefficiency of lipgloss disproportionately impacts our system, as all help
text for every command is generated whenever any command is invoked.

The `pretty` API could clean up a lot of the code (e.g., by replacing
complex string concatenations with Printf), but this commit is too
expansive as is so that work will be done in a follow up.
2023-09-07 16:28:22 -05:00
Mathias Fredriksson adba421524
refactor(coderd/telemetry): move CLI telemetry to cli/telemetry (#9517)
This change removes an indirect import of `coderd/database` from the
slim binary.

No size change (yet).

Ref: #9380
2023-09-04 21:42:45 +03:00
Mathias Fredriksson d2115941b7
refactor(cli)!: remove reset-password from slim binary (#9520)
This is an alternative approach to #9519 and removes 2 MB instead of 1
MB (1.2 MB accounted for by embedded migration SQL files).

Combined with #9481, #9506, #9508, #9517, a total of 5 MB is removed.

Ref: #9380
2023-09-04 19:38:53 +03:00
Mathias Fredriksson 702b064cac
refactor: split coderd/gitauth into two, add cli/gitauth (#9479)
* refactor: split coderd/gitauth into two, add cli/gitauth

Ref: #9380
2023-09-01 15:41:22 +00:00
Mathias Fredriksson f1f9cb030d
refactor(cli): avoid importing coderd in slim server (#9483)
This small change removes 11 MB from the slim binary size.

Ref: #9380
2023-09-01 13:32:21 +00:00
Ammar Bandukwala 6ba92ef924
ci: enable gocognit (#9359)
And, bring the server under 300:

* Removed the undocumented "disable" STUN address in favor of the
--disable-direct flag.
2023-08-27 14:46:44 -05:00
Marcin Tojek e845deaa89
fix: prompt when parameter options are incompatible (#9247) 2023-08-23 18:18:38 +02:00
Kyle Carberry 22e781eced
chore: add /v2 to import module path (#9072)
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00
Asher 37f9d4b783
feat: add --header-command flag (#9059)
This allows specifying a command to run that can output headers for
cases where users require dynamic headers (like to authenticate to their
VPN).

The primary use case is to add this flag in SSH configs created by the
VS Code plugin, although maybe config-ssh should do the same.
2023-08-14 12:12:17 -08:00
Spike Curtis cb4989cd8d
feat: add PSK for external provisionerd auth (#8877)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-04 12:32:28 +04:00
Steven Masley 4c4d966c7b
feat: add ability to make workspace for other user from cli (#8481)
* feat: add ability to make workspace for other user from cli
* Add example to show functionality
2023-07-14 09:48:02 -04:00
Colin Adler 9df80530d7
chore(cli): unhide `netcheck` command (#8412) 2023-07-10 21:38:02 -05:00
Cian Johnston 435c67ab75
refactor(cli)!: move scaletest to exp/scaletest (#8339)
* refactor(cli): mv scaletest exp/scaletest

* make gen
2023-07-07 09:10:14 +01:00
Cian Johnston 7fcf319e01
fix(cli)!: protect client Logger and refactor cli scaletest tests (#8317)
- (breaking) Protects Logger and LogBodies fields of codersdk.Client with its mutex. This addresses a data race in cli/scaletest.
- Fillets the existing cli/createworkspaces unit test and moves the testing logic there into the tests under scaletest/createworkspaces.
- Adds testutil.RaceEnabled bool const and conditionaly skips previously-skipped tests under scaletest/ if the race detector is enabled. This is unfortunate and sad, but I would prefer to have these tests at least running without the race detector than not running at all.
- Adds IgnoreErrors option to fake in-memory agent loggers; having the agents fail the test immediately when they encounter any sort of error isn't really helpful.
2023-07-06 09:43:39 +01:00
Steven Masley 4a008a8f34
chore: prevent nil dereferences on cmd handlers (#8319)
* chore: detect nil cmd handlers

Prevent nil panic dereferences on cmd handlers. Add a unit test
to prevent future mistakes
2023-07-05 17:20:12 +00:00
Dean Sheather 24b95e16c4
feat: add --disable-direct flag to CLI (#8131) 2023-06-21 20:22:43 +00:00
Colin Adler bc739bdfce
feat(cli): add hidden netcheck command (#8136) 2023-06-21 14:33:19 -05:00
Cian Johnston d6f8bd7847
feat(cli): add `coder stat` command (#8005) 2023-06-20 11:16:57 +02:00