Skip to content

Commit 78c4763

Browse files
committed
Add binary source and destination settings
1 parent d7b13f0 commit 78c4763

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
"markdownDescription": "If true, the extension will not verify the authenticity of the remote host. This is useful for self-signed certificates.",
4848
"type": "boolean",
4949
"default": false
50+
},
51+
"coder.binarySource": {
52+
"markdownDescription": "Used to download the Coder CLI which is necessary to make SSH connections. The If-None-Match header will be set to the SHA1 of the CLI and can be used for caching. Absolute URLs will be used as-is; otherwise this value will be resolved against the deployment domain. Defaults to downloading from the Coder deployment.",
53+
"type": "string",
54+
"default": ""
55+
},
56+
"coder.binaryDestination": {
57+
"markdownDescription": "The full path of the directory into which the Coder CLI will be downloaded. Defaults to the extension's global storage directory.",
58+
"type": "string",
59+
"default": ""
5060
}
5161
}
5262
},

src/storage.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export class Storage {
8888
if (!baseURL) {
8989
throw new Error("Must be logged in!")
9090
}
91-
const baseURI = vscode.Uri.parse(baseURL)
9291

9392
const buildInfo = await getBuildInfo()
9493
const binPath = this.binaryPath()
@@ -117,11 +116,16 @@ export class Storage {
117116
if (exists) {
118117
etag = await this.getBinaryETag()
119118
}
119+
120+
const configSource = vscode.workspace.getConfiguration().get("coder.binarySource")
121+
const binSource = configSource && String(configSource).trim().length > 0 ? String(configSource) : "/bin/" + binName
122+
120123
this.output.appendLine(`Using binName: ${binName}`)
121124
this.output.appendLine(`Using binPath: ${binPath}`)
125+
this.output.appendLine(`Using binSource: ${binSource}`)
122126
this.output.appendLine(`Using ETag: ${etag}`)
123127

124-
const resp = await axios.get("/bin/" + binName, {
128+
const resp = await axios.get(binSource, {
125129
signal: controller.signal,
126130
baseURL: baseURL,
127131
responseType: "stream",
@@ -146,7 +150,9 @@ export class Storage {
146150
const completed = await vscode.window.withProgress<boolean>(
147151
{
148152
location: vscode.ProgressLocation.Notification,
149-
title: `Downloading the latest binary (${buildInfo.version} from ${baseURI.authority})`,
153+
title: `Downloading the latest binary (${buildInfo.version} from ${axios.getUri(
154+
resp.config,
155+
)}) to ${binPath}`,
150156
cancellable: true,
151157
},
152158
async (progress, token) => {
@@ -260,7 +266,10 @@ export class Storage {
260266
// getBinaryCachePath returns the path where binaries are cached.
261267
// The caller must ensure it exists before use.
262268
public getBinaryCachePath(): string {
263-
return path.join(this.globalStorageUri.fsPath, "bin")
269+
const configPath = vscode.workspace.getConfiguration().get("coder.binaryDestination")
270+
return configPath && String(configPath).trim().length > 0
271+
? path.resolve(String(configPath))
272+
: path.join(this.globalStorageUri.fsPath, "bin")
264273
}
265274

266275
// getNetworkInfoPath returns the path where network information

0 commit comments

Comments
 (0)