Skip to content

Commit

Permalink
fix: conditionally create local-secrets-bean. (#13920)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryangul committed Sep 12, 2024
1 parent fde00dd commit 10eb8ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.airbyte.config.Configs
import io.airbyte.workers.process.Metadata.AWS_ACCESS_KEY_ID
import io.airbyte.workers.process.Metadata.AWS_SECRET_ACCESS_KEY
import io.airbyte.workload.launcher.constants.EnvVarConstants
import io.airbyte.workload.launcher.constants.EnvVarConstants.LOCAL_SECRETS_MICRONAUT_ENV
import io.airbyte.workload.launcher.model.toEnvVarList
import io.airbyte.workload.launcher.model.toRefEnvVarList
import io.fabric8.kubernetes.api.model.EnvVar
Expand Down Expand Up @@ -323,20 +324,28 @@ class EnvVarConfigBeanFactory {

/**
* Map of env vars for specifying the Micronaut environment.
* Indirectly necessary for configuring API client auth.
* Indirectly necessary for configuring API client auth and the local test secrets db
*/
@Singleton
@Named("micronautEnvMap")
fun micronautEnvMap(): Map<String, String> {
val envMap: MutableMap<String, String> = HashMap()
fun micronautEnvMap(
@Value("\${airbyte.secret.persistence}") secretPersistenceType: String,
): Map<String, String> {
val envs = mutableListOf(EnvVarConstants.WORKER_V2_MICRONAUT_ENV)

if (System.getenv(Environment.ENVIRONMENTS_ENV) != null) {
envMap[Environment.ENVIRONMENTS_ENV] = "${EnvVarConstants.WORKER_V2_MICRONAUT_ENV},${System.getenv(Environment.ENVIRONMENTS_ENV)}"
} else {
envMap[Environment.ENVIRONMENTS_ENV] = EnvVarConstants.WORKER_V2_MICRONAUT_ENV
// inherit from the parent env
System.getenv(Environment.ENVIRONMENTS_ENV)?.let {
envs.add(it)
}

return envMap
// add this conditionally to trigger datasource bean creation via application.yaml
if (secretPersistenceType == Configs.SecretPersistenceType.TESTING_CONFIG_DB_TABLE.toString()) {
envs.add(LOCAL_SECRETS_MICRONAUT_ENV)
}

val commaSeparatedEnvString = envs.joinToString(separator = ",")

return mapOf(Environment.ENVIRONMENTS_ENV to commaSeparatedEnvString)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ object EnvVarConstants {
const val ACCEPTANCE_TEST_ENABLED_VAR = "ACCEPTANCE_TEST_ENABLED"
const val DD_INTEGRATION_ENV_VAR_FORMAT = "DD_INTEGRATION_%s_ENABLED"
const val WORKER_V2_MICRONAUT_ENV = WorkloadConstants.WORKER_V2_MICRONAUT_ENV
const val LOCAL_SECRETS_MICRONAUT_ENV = "local-secrets"
const val WORKLOAD_API_HOST_ENV_VAR = "WORKLOAD_API_HOST"
const val WORKLOAD_API_CONNECT_TIMEOUT_SECONDS_ENV_VAR = "WORKLOAD_API_CONNECT_TIMEOUT_SECONDS"
const val WORKLOAD_API_READ_TIMEOUT_SECONDS_ENV_VAR = "WORKLOAD_API_READ_TIMEOUT_SECONDS"
Expand Down

0 comments on commit 10eb8ca

Please sign in to comment.