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

If an api token is not passed in the constructor, check the env variable #548

Merged
merged 6 commits into from
Nov 6, 2023

Conversation

elena-kolevska
Copy link
Contributor

Description

Adds the possibility to get an api token from the standard environment variable, as described in this proposal https://github.com/dapr/proposals/blob/main/0010-S-unified-api-token-env-variable.md

Issue reference

#547

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
@elena-kolevska elena-kolevska requested review from a team as code owners October 31, 2023 18:33
Copy link
Member

@shubham1172 shubham1172 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @elena-kolevska. Small nits and the lint is failing.

@@ -292,7 +292,7 @@ export function getClientOptions(
isKeepAlive: clientOptions?.isKeepAlive,
logger: clientOptions?.logger ?? defaultLoggerOptions,
actor: clientOptions?.actor,
daprApiToken: clientOptions?.daprApiToken,
daprApiToken: clientOptions?.daprApiToken ?? process.env.DAPR_API_TOKEN,
Copy link
Member

Choose a reason for hiding this comment

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

We can move this to Settings.util.ts for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about the same thing, but it seemed like we only use it when there is a default value. Let me try it out and see how it looks.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I noticed that in some cases we even have "" as the default, which essentially is the same as not having one.

test/unit/utils/Client.util.test.ts Outdated Show resolved Hide resolved
test/unit/utils/Client.util.test.ts Outdated Show resolved Hide resolved
elena-kolevska and others added 2 commits November 6, 2023 08:32
Co-authored-by: Shubham Sharma <shubhash@microsoft.com>
Signed-off-by: Elena Kolevska <elena-kolevska@users.noreply.github.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (0fb83c1) 100.00% compared to head (887f55c) 35.30%.

Additional details and impacted files
@@             Coverage Diff              @@
##              main     #548       +/-   ##
============================================
- Coverage   100.00%   35.30%   -64.70%     
============================================
  Files            1       91       +90     
  Lines            6    10447    +10441     
  Branches         1      411      +410     
============================================
+ Hits             6     3688     +3682     
- Misses           0     6700     +6700     
- Partials         0       59       +59     
Files Coverage Δ
src/utils/Settings.util.ts 75.00% <100.00%> (ø)
src/utils/Client.util.ts 43.26% <0.00%> (ø)

... and 88 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Elena Kolevska <elena@kolevska.com>
@shubham1172 shubham1172 added this pull request to the merge queue Nov 6, 2023
Merged via the queue into dapr:main with commit 66d4bd0 Nov 6, 2023
6 of 8 checks passed
@shubham1172 shubham1172 linked an issue Nov 7, 2023 that may be closed by this pull request
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.

Accept the api token through the DAPR_API_TOKEN environment variable
2 participants