-
Notifications
You must be signed in to change notification settings - Fork 9
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
RUMM-2346 Add more environment variables #109
Conversation
There was a problem hiding this 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
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) | ||
} |
There was a problem hiding this comment.
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," + |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes totally
setEnv(DdAndroidGradlePlugin.DD_API_KEY, "") | ||
setEnv(DdAndroidGradlePlugin.DATADOG_API_KEY, "") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 Report
@@ 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
|
a0cc277
to
1d84d3e
Compare
Co-authored-by: Bryce Eadie <bryce.eadie@datadoghq.com>
What does this PR do?
Enable reading site from
DATADOG_SITE
and api key fromDATADOG_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)