Skip to content

Commit

Permalink
Refactor apply*FromDatadogCIConfig
Browse files Browse the repository at this point in the history
Make logic flow between the two functions the same
  • Loading branch information
fuzzybinary committed Feb 1, 2024
1 parent 35c58dd commit ef9dbec
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ abstract class DdFileUploadTask @Inject constructor(
if (this.apiKeySource == ApiKeySource.GRADLE_PROPERTY) {
DdAndroidGradlePlugin.LOGGER.info(
"API key found in Datadog CI config file, but it will be ignored," +
" because also an explicit one was provided as a gradle property."
" because also an explicit one was provided as a gradle property."
)
} else {
DdAndroidGradlePlugin.LOGGER.info("API key found in Datadog CI config file, using it.")
Expand All @@ -240,21 +240,21 @@ abstract class DdFileUploadTask @Inject constructor(
}

private fun applySiteFromDatadogCiConfig(config: JSONObject) {
if (this.site.isNotEmpty()) {
DdAndroidGradlePlugin.LOGGER.info(
"Site property found in Datadog CI config file, but it will be ignored," +
" because also an explicit one was provided in extension."
)
return
}
val siteAsDomain = config.optString(DATADOG_CI_SITE_PROPERTY, null)
if (!siteAsDomain.isNullOrEmpty()) {
val site = DatadogSite.fromDomain(siteAsDomain)
if (site == null) {
DdAndroidGradlePlugin.LOGGER.warn("Unknown Datadog domain provided: $siteAsDomain, ignoring it.")
if (this.site.isNotEmpty()) {
DdAndroidGradlePlugin.LOGGER.info(
"Site property found in Datadog CI config file, but it will be ignored," +
" because also an explicit one was provided in extension."
)
} else {
DdAndroidGradlePlugin.LOGGER.info("Site property found in Datadog CI config file, using it.")
this.site = site.name
val site = DatadogSite.fromDomain(siteAsDomain)
if (site == null) {
DdAndroidGradlePlugin.LOGGER.warn("Unknown Datadog domain provided: $siteAsDomain, ignoring it.")
} else {
DdAndroidGradlePlugin.LOGGER.info("Site property found in Datadog CI config file, using it.")
this.site = site.name
}
}
}
}
Expand Down

0 comments on commit ef9dbec

Please sign in to comment.