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

Conversation

evhen14
Copy link
Contributor

@evhen14 evhen14 commented Mar 27, 2024

Resolving issue #326

There is a "standard" way for running processes. However, the original implementation is not using it. Lacking understanding why it was done this way, I only extended the current implementation.

@evhen14 evhen14 force-pushed the support-env-vars branch 2 times, most recently from afe4a42 to 0812e40 Compare March 27, 2024 22:54
@evhen14
Copy link
Contributor Author

evhen14 commented Mar 27, 2024

@microsoft-github-policy-service agree

@evhen14
Copy link
Contributor Author

evhen14 commented Apr 2, 2024

@philliphoff is it possible to get a review for this PR.

@philliphoff
Copy link
Collaborator

There is a "standard" way for running processes. However, the original implementation is not using it. Lacking understanding why it was done this way, I only extended the current implementation.

@evhen14 Much of the task implementation is from the early days of VS Code's custom task support, before there was better integration with the shell/terminal. What would you consider to be the "standard" way.

@@ -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.

@yevgen-el8
Copy link
Contributor

There is a "standard" way for running processes. However, the original implementation is not using it. Lacking understanding why it was done this way, I only extended the current implementation.

@evhen14 Much of the task implementation is from the early days of VS Code's custom task support, before there was better integration with the shell/terminal. What would you consider to be the "standard" way.

I'm new to VS Code extensions and it seems like https://code.visualstudio.com/api/references/vscode-api#ProcessExecution does take into account the options from the task definition and that's what I refer to.

@philliphoff
Copy link
Collaborator

I'm new to VS Code extensions and it seems like https://code.visualstudio.com/api/references/vscode-api#ProcessExecution does take into account the options from the task definition and that's what I refer to.

@yevgen-el8 It looks like ProcessExecution will automatically merge the parent process environment, but would still rely on explicitly merging the environment from the task definition. Another downside to ProcessExecution is, as far as I can tell, that you don't notification of output or completion, which is necessary for custom tasks.

Copy link
Collaborator

@philliphoff philliphoff left a comment

Choose a reason for hiding this comment

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

Looks good overall. I think the only thing left is to flesh out the task definitions for both dapr and daprd tasks (e.g. to include the env property on the option property).

@yevgen-el8
Copy link
Contributor

Looks good overall. I think the only thing left is to flesh out the task definitions for both dapr and daprd tasks (e.g. to include the env property on the option property).

I'm not sure what you mean there. The task definition already has options defined and Options interface has env property

@philliphoff
Copy link
Collaborator

I'm not sure what you mean there. The task definition already has options defined and Options interface has env property

@yevgen-el8 Sorry, I meant the task JSON schema definition in the package.json.

@evhen14
Copy link
Contributor Author

evhen14 commented Apr 10, 2024

I'm not sure what you mean there. The task definition already has options defined and Options interface has env property

@yevgen-el8 Sorry, I meant the task JSON schema definition in the package.json.

@philliphoff Thank you. Please have a look.

Copy link
Collaborator

@philliphoff philliphoff left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the contribution!

@philliphoff philliphoff merged commit 481fd0f into microsoft:main Apr 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants