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 }