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

RUMM-2346 Add more environment variables #109

Merged

Conversation

louiszawadzki
Copy link
Contributor

What does this PR do?

Enable reading site from DATADOG_SITE and api key from DATADOG_API_KEY

Motivation

Harmonizing env variable names across the Gradle plugin and datadog-ci

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@louiszawadzki louiszawadzki requested review from a team as code owners August 24, 2022 09:32
Copy link
Member

@0xnm 0xnm left a comment

Choose a reason for hiding this comment

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

lgtm! I've left some comments, but they are not blocking for me

Comment on lines 62 to +68
val environmentKey = System.getenv(DD_API_KEY)
if (!environmentKey.isNullOrBlank()) return ApiKey(environmentKey, ApiKeySource.ENVIRONMENT)

val alternativeEnvironmentKey = System.getenv(DATADOG_API_KEY)
if (!alternativeEnvironmentKey.isNullOrBlank()) {
return ApiKey(alternativeEnvironmentKey, ApiKeySource.ENVIRONMENT)
}
Copy link
Member

Choose a reason for hiding this comment

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

can be also written like:

val envKey = listOf(System.getenv(DD_API_KEY), System.getenv(DATADOG_API_KEY))
                          .firstOrNull { !it.isNullOrBlank() }
if (envKey != null) ...

but I'm also fine with introducing another variable, it is a minor thing anyway

private fun applySiteFromEnvironment() {
if (this.site.isNotEmpty()) {
LOGGER.info(
"Site property found as DATADOG_SITE env variable, but it will be ignored," +
Copy link
Member

Choose a reason for hiding this comment

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

seems like this message is misleading, we don't know at this step if env DATADOG_SITE exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I'll change that!

)
return
}
val environmentKey = System.getenv(DATADOG_SITE)
Copy link
Member

Choose a reason for hiding this comment

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

it is not a key, but a value of env variable, better to rename it. maybe envSite or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes totally

Comment on lines +81 to +82
setEnv(DdAndroidGradlePlugin.DD_API_KEY, "")
setEnv(DdAndroidGradlePlugin.DATADOG_API_KEY, "")
Copy link
Member

Choose a reason for hiding this comment

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

is it mostly for cleanup? per code logic having an empty value is not different from not having env variable at all, so it seems these 2 lines don't make any change compared to the current setup (only if to clean up values set by some tests).

If it is for the cleanup, maybe it is better to remove env variables for the clean state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's for cleanup, the test for DATADOG_API_KEY wasn't passing when executed after the DD_API_KEY test.
How do you remove env variables in kotlin?

Copy link
Member

Choose a reason for hiding this comment

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

interesting, it seems there is no easy way to delete them

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2022

Codecov Report

Merging #109 (7c07d68) into develop (0e65323) will decrease coverage by 1.19%.
The diff coverage is 46.67%.

@@              Coverage Diff              @@
##             develop     #109      +/-   ##
=============================================
- Coverage      88.45%   87.26%   -1.19%     
- Complexity       163      168       +5     
=============================================
  Files             21       21              
  Lines            511      526      +15     
  Branches          61       65       +4     
=============================================
+ Hits             452      459       +7     
- Misses            38       42       +4     
- Partials          21       25       +4     
Impacted Files Coverage Δ
...m/datadog/gradle/plugin/DdMappingFileUploadTask.kt 88.97% <41.67%> (-4.58%) ⬇️
...com/datadog/gradle/plugin/DdAndroidGradlePlugin.kt 74.14% <66.67%> (-0.20%) ⬇️

@louiszawadzki louiszawadzki force-pushed the louiszawadzki/rumm-2346/add-more-environment-variables branch from a0cc277 to 1d84d3e Compare August 24, 2022 11:14
buraizu
buraizu previously approved these changes Aug 24, 2022
@buraizu buraizu dismissed their stale review August 24, 2022 23:48

Noticed a minor copy issue

docs/upload_mapping_file.md Outdated Show resolved Hide resolved
docs/upload_mapping_file.md Outdated Show resolved Hide resolved
Co-authored-by: Bryce Eadie <bryce.eadie@datadoghq.com>
@louiszawadzki louiszawadzki merged commit c5cecfc into develop Aug 25, 2022
@louiszawadzki louiszawadzki deleted the louiszawadzki/rumm-2346/add-more-environment-variables branch August 25, 2022 09:13
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.

5 participants