Skip to content

Commit

Permalink
replace if / else with let in evaluateEnvVariablesInGitRepoURI
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrishnan83 committed May 12, 2024
1 parent 0af1429 commit d415b0e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core/src/main/kotlin/in/specmatic/core/git/GitOperations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,11 @@ fun evaluateEnvVariablesInGitRepoURI(gitRepositoryURI: String, environmentVariab
val envVariableMatches = envVariableRegex.findAll(gitRepositoryURI)
envVariableMatches.forEach { matchResult ->
val envVariable = matchResult.groupValues[1]
if (environmentVariables.containsKey(envVariable)) {
val envVariableValue = environmentVariables.getValue(envVariable)
environmentVariables[envVariable]?.let { envVariableValue ->
logger.log("Evaluating $envVariable in $gitRepositoryURI")
evaluatedGitRepoUrl = evaluatedGitRepoUrl.replace("\${$envVariable}", envVariableValue)
} else {
logger.log("$envVariable in $gitRepositoryURI resembles an environment variable, but it is not available in the environment variables. Skipping evaluation.")
}
?: logger.log("$envVariable in $gitRepositoryURI resembles an environment variable, but skipping evaluation since value for the same is not set.")
}
return evaluatedGitRepoUrl
}
Expand Down

0 comments on commit d415b0e

Please sign in to comment.