overriddenConnectionMode function
Parses the TESTCONTAINERS_CONNECTION_MODE environment variable.
Returns the corresponding ConnectionMode value, or null when the
variable is absent or empty.
Throws ArgumentError when the variable is set to an unrecognised value.
Implementation
ConnectionMode? overriddenConnectionMode() {
final val = Platform.environment['TESTCONTAINERS_CONNECTION_MODE'];
if (val == null || val.isEmpty) {
return null;
}
return switch (val) {
'bridge_ip' => ConnectionMode.bridgeIp,
'gateway_ip' => ConnectionMode.gatewayIp,
'docker_host' => ConnectionMode.dockerHost,
_ => throw ArgumentError(
'Error parsing TESTCONTAINERS_CONNECTION_MODE value "$val". '
'Expected one of: bridge_ip, gateway_ip, docker_host.',
),
};
}