Skip to content

Commit a5941a3

Browse files
authored
feat: support configurable CLI global config (#1011)
- Add `coder.globalConfig` machine-scoped setting to control the CLI `--global-config` path; falls back to `CODER_CONFIG_DIR`, then the existing per-deployment `<globalStorage>/<safeHost>` default - Propagate the resolved config dir through `PathResolver`, CLI auth flags, credential file reads/writes/deletes, active remote reload prompts, and support bundle settings - On CLI 2.31+: delegate credential writes to `coder login` and deletes to `coder logout --global-config <dir>` instead of the extension touching files directly - On CLI 2.31+ (file mode): read file-backed CLI credentials so the extension can share a login with the terminal `coder` binary - Preserve keyring precedence (macOS/Windows, 2.29+); no behavior change for keyring users - Prevent `coder.globalFlags` from overriding the managed `--global-config` / `--use-keyring` flags - Move binary cache out of the per-deployment dir; always use the plugin dir (`coder.binaryDestination` still applies) Closes #185
1 parent 738151e commit a5941a3

35 files changed

Lines changed: 1196 additions & 699 deletions

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
raw output. When a slow connection is detected, the network status bar
1919
tooltip also links to the network check alongside the latency test, for a
2020
deployment-wide view of the network path.
21+
- Share login with the terminal `coder` CLI by setting `--global-config=<dir>`
22+
in `coder.globalFlags`; the extension reads file-based CLI credentials from
23+
that directory (requires a deployment on 2.31.0+).
24+
25+
### Changed
26+
27+
- File-based credentials are now written and cleared through `coder login` and
28+
`coder logout` rather than by the extension directly. The minimum supported
29+
Coder version is now v0.25.0.
2130

2231
### Fixed
2332

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"scope": "machine"
183183
},
184184
"coder.globalFlags": {
185-
"markdownDescription": "Global flags to pass to every Coder CLI invocation. Enter each flag as a separate array item, in order. Do **not** include the `coder` command itself. See the [CLI reference](https://coder.com/docs/reference/cli) for available global flags.\n\nSupports `${env:VAR}`, `${userHome}`, and a leading `~`. For `--flag=value` items the expansion applies to the value half, so `--cfg=~/coder` works.\n\nFor `--header-command`, precedence is: `#coder.headerCommand#` setting, then `CODER_HEADER_COMMAND` environment variable, then the value specified here. The `--global-config` and `--use-keyring` flags are silently ignored as the extension manages them via `#coder.useKeyring#`.",
185+
"markdownDescription": "Global flags to pass to every Coder CLI invocation. Enter each flag as a separate array item, in order. Do **not** include the `coder` command itself. See the [CLI reference](https://coder.com/docs/reference/cli) for available global flags.\n\nSupports `${env:VAR}`, `${userHome}`, and a leading `~`. For `--flag=value` items the expansion applies to the value half, so `--cfg=~/coder` works.\n\nSet `--global-config` here to point the CLI at a shared config directory (e.g. `--global-config=~/.config/coderv2` to share login/auth with the Coder CLI); requires a deployment on 2.31.0+ and is ignored when `#coder.useKeyring#` is active. The `--use-keyring` flag is ignored; use `#coder.useKeyring#` instead.\n\nFor `--header-command`, precedence is: `#coder.headerCommand#` setting, then `CODER_HEADER_COMMAND` environment variable, then the value specified here.",
186186
"type": "array",
187187
"items": {
188188
"type": "string"

src/api/authInterceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type AxiosError, isAxiosError } from "axios";
22

33
import { AuthTelemetry } from "../instrumentation/auth";
44
import { OAuthError } from "../oauth/errors";
5-
import { toSafeHost } from "../util";
5+
import { toSafeHost } from "../util/uri";
66

77
import type * as vscode from "vscode";
88

src/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import {
4646
import { resolveCliAuth } from "./settings/cli";
4747
import { appendVsCodeLogs } from "./supportBundle/appendVsCodeLogs";
4848
import { runExportTelemetryCommand } from "./telemetry/export/command";
49-
import { openInBrowser, toRemoteAuthority, toSafeHost } from "./util";
49+
import { toRemoteAuthority } from "./util/authority";
50+
import { openInBrowser, toSafeHost } from "./util/uri";
5051
import { vscodeProposed } from "./vscodeProposed";
5152
import { parseNetcheckReport } from "./webviews/netcheck/types";
5253
import { parseSpeedtestResult } from "./webviews/speedtest/types";

0 commit comments

Comments
 (0)