From 0812e40ef9165f11e4605ca75f2dedea67a2b8c5 Mon Sep 17 00:00:00 2001 From: Yevgen Polyak Date: Thu, 28 Mar 2024 11:39:29 +1300 Subject: [PATCH] Support passing environment variables to dapr cli --- package-lock.json | 5 +++-- package.json | 6 +++++- package.nls.json | 1 + src/tasks/daprCommandTaskProvider.ts | 4 ++-- src/tasks/taskDefinition.ts | 9 +++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1a88b4e..761d9ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-dapr", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-dapr", - "version": "0.8.0", + "version": "0.8.1", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@microsoft/vscode-azext-utils": "^2.1.1", @@ -3290,6 +3290,7 @@ "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.7.0.tgz", "integrity": "sha512-YEY9HWqThQc5q5xbXbRwsZTh2PJ36OSYRjSv3NN2xf5s5dpLTjEZnC2YikR29OaVybf9nQ0dJ/80i40RS97t/A==", "dev": true, + "hasInstallScript": true, "dependencies": { "node-addon-api": "^3.0.0", "prebuild-install": "^6.0.0" diff --git a/package.json b/package.json index 1edd8d8..b0d3e2c 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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%" diff --git a/package.nls.json b/package.nls.json index 2de95f1..32e591f 100644 --- a/package.nls.json +++ b/package.nls.json @@ -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 \"/.dapr/components\").", "vscode-dapr.tasks.dapr.properties.resourcesPaths.description": "The paths for resources directory (default \"/.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.", diff --git a/src/tasks/daprCommandTaskProvider.ts b/src/tasks/daprCommandTaskProvider.ts index c6f5644..d600fc8 100644 --- a/src/tasks/daprCommandTaskProvider.ts +++ b/src/tasks/daprCommandTaskProvider.ts @@ -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) }); } } @@ -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.')); } diff --git a/src/tasks/taskDefinition.ts b/src/tasks/taskDefinition.ts index 49ec0ea..9d5ab2b 100644 --- a/src/tasks/taskDefinition.ts +++ b/src/tasks/taskDefinition.ts @@ -7,8 +7,17 @@ export interface DependsOn { type?: string; } +export interface Dictionary { + [Key: string]: T; +} + +export interface Options { + env?: Dictionary +} + export interface TaskDefinition extends vscode.TaskDefinition { cwd?: string; + options?: Options; dependsOn?: string | string[] | DependsOn; label?: string; }