Skip to content

Commit c6f5855

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

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

package.json

+10
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

+13-3
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ export class Storage {
117117
if (exists) {
118118
etag = await this.getBinaryETag()
119119
}
120+
121+
const configSource = vscode.workspace.getConfiguration().get("coder.binarySource")
122+
const binSource = configSource && String(configSource).trim().length > 0
123+
? String(configSource)
124+
: "/bin/" + binName
125+
120126
this.output.appendLine(`Using binName: ${binName}`)
121127
this.output.appendLine(`Using binPath: ${binPath}`)
128+
this.output.appendLine(`Using binSource: ${binSource}`)
122129
this.output.appendLine(`Using ETag: ${etag}`)
123130

124-
const resp = await axios.get("/bin/" + binName, {
131+
const resp = await axios.get(binSource, {
125132
signal: controller.signal,
126133
baseURL: baseURL,
127134
responseType: "stream",
@@ -146,7 +153,7 @@ export class Storage {
146153
const completed = await vscode.window.withProgress<boolean>(
147154
{
148155
location: vscode.ProgressLocation.Notification,
149-
title: `Downloading the latest binary (${buildInfo.version} from ${baseURI.authority})`,
156+
title: `Downloading the latest binary (${buildInfo.version} from ${axios.getUri(resp.config)}) to ${binPath}`,
150157
cancellable: true,
151158
},
152159
async (progress, token) => {
@@ -260,7 +267,10 @@ export class Storage {
260267
// getBinaryCachePath returns the path where binaries are cached.
261268
// The caller must ensure it exists before use.
262269
public getBinaryCachePath(): string {
263-
return path.join(this.globalStorageUri.fsPath, "bin")
270+
const configPath = vscode.workspace.getConfiguration().get("coder.binaryDestination")
271+
return configPath && String(configPath).trim().length > 0
272+
? path.resolve(String(configPath))
273+
: path.join(this.globalStorageUri.fsPath, "bin")
264274
}
265275

266276
// getNetworkInfoPath returns the path where network information

0 commit comments

Comments
 (0)