Skip to content

Commit 2d6ae42

Browse files
committed
feat: fallback to env var if configuration not set
1 parent feb4971 commit 2d6ae42

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.DS_Store

6 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"default": ""
6565
},
6666
"coder.headerCommand": {
67-
"markdownDescription": "An external command that outputs additional HTTP headers added to all requests. The command must output each header as `key=value` on its own line. The following environment variables will be available to the process: `CODER_URL`.",
67+
"markdownDescription": "An external command that outputs additional HTTP headers added to all requests. The command must output each header as `key=value` on its own line. The following environment variables will be available to the process: `CODER_URL`. Defaults to the value of `CODER_HEADER_COMMAND` if not set.",
6868
"type": "string",
6969
"default": ""
7070
},
@@ -291,4 +291,4 @@
291291
"trim": "0.0.3",
292292
"word-wrap": "1.2.5"
293293
}
294-
}
294+
}

src/remote.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ export class Remote {
537537

538538
// Add headers from the header command.
539539
let headerArg = ""
540-
const headerCommand = vscode.workspace.getConfiguration().get("coder.headerCommand")
540+
const headerCommand =
541+
vscode.workspace.getConfiguration().get("coder.headerCommand") || process.env.CODER_HEADER_COMMAND
541542
if (typeof headerCommand === "string" && headerCommand.trim().length > 0) {
542543
headerArg = ` --header-command ${escape(headerCommand)}`
543544
}

src/storage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,13 @@ export class Storage {
397397
}
398398

399399
public async getHeaders(url = this.getURL()): Promise<Record<string, string>> {
400-
return getHeaders(url, vscode.workspace.getConfiguration().get("coder.headerCommand"), this)
400+
console.log(process.env)
401+
402+
return getHeaders(
403+
url,
404+
vscode.workspace.getConfiguration().get("coder.headerCommand") || process.env.CODER_HEADER_COMMAND,
405+
this,
406+
)
401407
}
402408
}
403409

0 commit comments

Comments
 (0)