Skip to content

Commit

Permalink
Support passing environment variables to dapr cli
Browse files Browse the repository at this point in the history
  • Loading branch information
yevgen-el8 committed Mar 27, 2024
1 parent 0f6642f commit 0812e40
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Dapr",
"description": "Makes it easy to run, debug, and interact with Dapr-enabled applications.",
"icon": "assets/images/extensionIcon.png",
"version": "0.8.0",
"version": "0.8.1",
"preview": true,
"publisher": "ms-azuretools",
"license": "SEE LICENSE IN LICENSE.txt",
Expand Down Expand Up @@ -484,6 +484,10 @@
"type": "string",
"description": "%vscode-dapr.tasks.dapr.properties.runFile.description%"
},
"options": {
"type": "object",
"description": "%vscode-dapr.tasks.dapr.properties.options.description%"
},
"unixDomainSocket": {
"type": "string",
"description": "%vscode-dapr.tasks.dapr.properties.unixDomainSocket.description%"
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"vscode-dapr.tasks.dapr.properties.profilePort.description": "The port for the profile server to listen on.",
"vscode-dapr.tasks.dapr.properties.resourcesPath.description": "(Deprecated in v1.11.) The path for resources directory (default \"<user>/.dapr/components\").",
"vscode-dapr.tasks.dapr.properties.resourcesPaths.description": "The paths for resources directory (default \"<user>/.dapr/components\").",
"vscode-dapr.tasks.dapr.properties.options.description": "Task options.",
"vscode-dapr.tasks.dapr.properties.runFile.description": "Path to the run template file for the list of apps to run.",
"vscode-dapr.tasks.dapr.properties.unixDomainSocket.description": "Path to a unix domain socket dir. If specified, Dapr API servers will use Unix Domain Sockets.",

Expand Down
4 changes: 2 additions & 2 deletions src/tasks/daprCommandTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class DaprCommandTaskProvider extends CommandTaskProvider {
// if any property being set means do not need to infer dapr.yaml
if (Object.prototype.hasOwnProperty.call(daprDefinition, def) && def !== "type" && def !== undefined) {
const command = createCommandLineBuilder(daprPathProvider, daprDefinition).build();
return callback(command, { cwd: definition.cwd });
return callback(command, { cwd: definition.cwd, env: Object.assign({}, definition.options?.env, process.env) });
}
}

Expand All @@ -86,7 +86,7 @@ export default class DaprCommandTaskProvider extends CommandTaskProvider {
await checkFileExists(runFilePath).then((fileExists) => {
if (fileExists) {
const command = createCommandLineBuilder(daprPathProvider, { type: 'dapr', runFile: runFilePath }).build();
return callback(command, { cwd: definition.cwd });
return callback(command, { cwd: definition.cwd, env: Object.assign({}, definition.options?.env, process.env) });
} else {
throw new Error(localize('tasks.daprCommandTaskProvider.noRunFile', 'there is no dapr.yaml in this folder or workspace.'));
}
Expand Down
9 changes: 9 additions & 0 deletions src/tasks/taskDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ export interface DependsOn {
type?: string;
}

export interface Dictionary<T> {
[Key: string]: T;
}

export interface Options {
env?: Dictionary<string>
}

export interface TaskDefinition extends vscode.TaskDefinition {
cwd?: string;
options?: Options;
dependsOn?: string | string[] | DependsOn;
label?: string;
}

0 comments on commit 0812e40

Please sign in to comment.