Skip to content

feat: fall back to CODER_HEADER_COMMAND environment variable if not set #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: fallback to env var if configuration not set
  • Loading branch information
JoshVee committed Nov 3, 2023
commit 2d6ae426c83fe6d0ac64f448f4bdd757668123cc
Binary file added .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"default": ""
},
"coder.headerCommand": {
"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`.",
"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.",
"type": "string",
"default": ""
},
Expand Down Expand Up @@ -291,4 +291,4 @@
"trim": "0.0.3",
"word-wrap": "1.2.5"
}
}
}
3 changes: 2 additions & 1 deletion src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ export class Remote {

// Add headers from the header command.
let headerArg = ""
const headerCommand = vscode.workspace.getConfiguration().get("coder.headerCommand")
const headerCommand =
vscode.workspace.getConfiguration().get("coder.headerCommand") || process.env.CODER_HEADER_COMMAND
if (typeof headerCommand === "string" && headerCommand.trim().length > 0) {
headerArg = ` --header-command ${escape(headerCommand)}`
}
Expand Down
8 changes: 7 additions & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,13 @@ export class Storage {
}

public async getHeaders(url = this.getURL()): Promise<Record<string, string>> {
return getHeaders(url, vscode.workspace.getConfiguration().get("coder.headerCommand"), this)
console.log(process.env)

return getHeaders(
url,
vscode.workspace.getConfiguration().get("coder.headerCommand") || process.env.CODER_HEADER_COMMAND,
this,
)
}
}

Expand Down