Skip to content

Commit 10eb8ca

Browse files
committed
fix: conditionally create local-secrets-bean. (#13920)
1 parent fde00dd commit 10eb8ca

File tree

4 files changed

+18
-27
lines changed

4 files changed

+18
-27
lines changed

airbyte-workload-init-container/src/main/resources/application-oss.yml

-19
This file was deleted.

airbyte-workload-launcher/src/main/kotlin/config/EnvVarConfigBeanFactory.kt

+17-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import io.airbyte.config.Configs
1313
import io.airbyte.workers.process.Metadata.AWS_ACCESS_KEY_ID
1414
import io.airbyte.workers.process.Metadata.AWS_SECRET_ACCESS_KEY
1515
import io.airbyte.workload.launcher.constants.EnvVarConstants
16+
import io.airbyte.workload.launcher.constants.EnvVarConstants.LOCAL_SECRETS_MICRONAUT_ENV
1617
import io.airbyte.workload.launcher.model.toEnvVarList
1718
import io.airbyte.workload.launcher.model.toRefEnvVarList
1819
import io.fabric8.kubernetes.api.model.EnvVar
@@ -323,20 +324,28 @@ class EnvVarConfigBeanFactory {
323324

324325
/**
325326
* Map of env vars for specifying the Micronaut environment.
326-
* Indirectly necessary for configuring API client auth.
327+
* Indirectly necessary for configuring API client auth and the local test secrets db
327328
*/
328329
@Singleton
329330
@Named("micronautEnvMap")
330-
fun micronautEnvMap(): Map<String, String> {
331-
val envMap: MutableMap<String, String> = HashMap()
331+
fun micronautEnvMap(
332+
@Value("\${airbyte.secret.persistence}") secretPersistenceType: String,
333+
): Map<String, String> {
334+
val envs = mutableListOf(EnvVarConstants.WORKER_V2_MICRONAUT_ENV)
332335

333-
if (System.getenv(Environment.ENVIRONMENTS_ENV) != null) {
334-
envMap[Environment.ENVIRONMENTS_ENV] = "${EnvVarConstants.WORKER_V2_MICRONAUT_ENV},${System.getenv(Environment.ENVIRONMENTS_ENV)}"
335-
} else {
336-
envMap[Environment.ENVIRONMENTS_ENV] = EnvVarConstants.WORKER_V2_MICRONAUT_ENV
336+
// inherit from the parent env
337+
System.getenv(Environment.ENVIRONMENTS_ENV)?.let {
338+
envs.add(it)
337339
}
338340

339-
return envMap
341+
// add this conditionally to trigger datasource bean creation via application.yaml
342+
if (secretPersistenceType == Configs.SecretPersistenceType.TESTING_CONFIG_DB_TABLE.toString()) {
343+
envs.add(LOCAL_SECRETS_MICRONAUT_ENV)
344+
}
345+
346+
val commaSeparatedEnvString = envs.joinToString(separator = ",")
347+
348+
return mapOf(Environment.ENVIRONMENTS_ENV to commaSeparatedEnvString)
340349
}
341350

342351
/**

airbyte-workload-launcher/src/main/kotlin/constants/EnvVarConstants.kt

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ object EnvVarConstants {
2727
const val ACCEPTANCE_TEST_ENABLED_VAR = "ACCEPTANCE_TEST_ENABLED"
2828
const val DD_INTEGRATION_ENV_VAR_FORMAT = "DD_INTEGRATION_%s_ENABLED"
2929
const val WORKER_V2_MICRONAUT_ENV = WorkloadConstants.WORKER_V2_MICRONAUT_ENV
30+
const val LOCAL_SECRETS_MICRONAUT_ENV = "local-secrets"
3031
const val WORKLOAD_API_HOST_ENV_VAR = "WORKLOAD_API_HOST"
3132
const val WORKLOAD_API_CONNECT_TIMEOUT_SECONDS_ENV_VAR = "WORKLOAD_API_CONNECT_TIMEOUT_SECONDS"
3233
const val WORKLOAD_API_READ_TIMEOUT_SECONDS_ENV_VAR = "WORKLOAD_API_READ_TIMEOUT_SECONDS"

0 commit comments

Comments
 (0)