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).
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#10925Fixes#9551
* 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
This feature is used by the coder agent to exchange a new token. By
protecting the SessionToken via mutex we ensure there are no data races
when accessing it.
* fix: Change uses of t.Cleanup -> defer in test bodies
Mixing t.Cleanup and defer can lead to unexpected order of execution.
* fix: Ensure t.Cleanup is not aborted by require
* chore: Add helper annotations
* delete API token in logout api
* add deleteapikeybyid to databasefake
* set blank cookie on logout always
* refactor logout flow, add unit tests
* update logout messsage
* use read-only file mode for windows
* fix file mode on windows for cleanup
* change file permissions on windows
* assert error is not nil
* refactor cli
* try different file mode on windows
* try different file mode on windows
* try keeping the files open on Windows
* fix the error message on Windows
* Improve CLI logout flow
* Fix lint error
* Make notLoggedInMessage a const
* successful logout with a msg when cfg files are absent
* use require, os.remove, show only one message, add prompt