From b09b78de0896a478b5e8f84d238b9bddbd5c3523 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Wed, 20 Nov 2024 16:38:16 +0200 Subject: [PATCH] Explicitly disable plugin when `MIRRORD_ACTIVE=0` (#298) * explicitly disable plugin when `MIRRORD_ACTIVE=0` * add changelog --- changelog.d/+explicitly-disable-from-env.added.md | 1 + .../main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/+explicitly-disable-from-env.added.md diff --git a/changelog.d/+explicitly-disable-from-env.added.md b/changelog.d/+explicitly-disable-from-env.added.md new file mode 100644 index 00000000..175f9795 --- /dev/null +++ b/changelog.d/+explicitly-disable-from-env.added.md @@ -0,0 +1 @@ +Setting `MIRRORD_ACTIVE=0` environment variable will explicitly disable mirrord. diff --git a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt index dae50b7f..40719110 100644 --- a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt +++ b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordExecManager.kt @@ -99,8 +99,10 @@ class MirrordExecManager(private val service: MirrordProjectService) { projectEnvVars: Map? ): MirrordExecution? { MirrordLogger.logger.debug("MirrordExecManager.start") - val explicitlyEnabled = projectEnvVars?.any { (key, value) -> key == "MIRRORD_ACTIVE" && value == "1" } ?: false - if (!service.enabled && !explicitlyEnabled) { + val mirrordActiveValue = projectEnvVars?.get("MIRRORD_ACTIVE") + val explicitlyEnabled = mirrordActiveValue == "1" + val explicitlyDisabled = mirrordActiveValue == "0" + if ((!service.enabled && !explicitlyEnabled) || explicitlyDisabled) { MirrordLogger.logger.debug("disabled, returning") return null }