Skip to content
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

Support passing environment variables to dapr cli #327

Merged
merged 3 commits into from
Apr 18, 2024
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
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 execution 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) });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, it'd be great to support this in the daprdCommandTaskProvider and daprdDownTaskProvider as well.

Copy link
Contributor

@yevgen-el8 yevgen-el8 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add env for the daprd command. The daprdDownTaskProvider doesn't need env variables as it only sends SIGKILL to the existing process.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

} 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;
}
Loading