refactor: env handling
target specific env's rather than looping through them all
This commit is contained in:
+6
-7
@@ -58,21 +58,20 @@ fn setup_tracing() {
|
|||||||
/// An ENV is set in the ./containerised/Dockerfile, if this is ENV found, then sleep for 250ms, else the container, for as yet unknown reasons, will close immediately
|
/// An ENV is set in the ./containerised/Dockerfile, if this is ENV found, then sleep for 250ms, else the container, for as yet unknown reasons, will close immediately
|
||||||
/// returns a bool, so that the `update_all_containers()` won't bother to check the entry point unless running via a container
|
/// returns a bool, so that the `update_all_containers()` won't bother to check the entry point unless running via a container
|
||||||
fn check_if_containerised() -> bool {
|
fn check_if_containerised() -> bool {
|
||||||
if std::env::vars().any(|x| x == (ENV_KEY.into(), ENV_VALUE.into())) {
|
if let Ok(value) = std::env::var(ENV_KEY) {
|
||||||
|
if value == ENV_VALUE {
|
||||||
std::thread::sleep(std::time::Duration::from_millis(250));
|
std::thread::sleep(std::time::Duration::from_millis(250));
|
||||||
true
|
return true;
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read the optional docker_host path, the cli args take priority over the DOCKER_HOST env
|
/// Read the optional docker_host path, the cli args take priority over the DOCKER_HOST env
|
||||||
fn read_docker_host(args: &CliArgs) -> Option<String> {
|
fn read_docker_host(args: &CliArgs) -> Option<String> {
|
||||||
args.host.as_ref().map_or_else(
|
args.host.as_ref().map_or_else(
|
||||||
|| {
|
|| {
|
||||||
std::env::vars()
|
std::env::var(DOCKER_HOST).ok()
|
||||||
.find(|x| x.0 == DOCKER_HOST)
|
|
||||||
.map(|(_, val)| val)
|
|
||||||
},
|
},
|
||||||
|x| Some(x.to_string()),
|
|x| Some(x.to_string()),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user