From 58f493707f956b5cb4f991747bf71ba81d9c13d2 Mon Sep 17 00:00:00 2001 From: Charlotte Andersson Date: Mon, 10 Jun 2024 12:27:54 +0200 Subject: [PATCH] fix: set linkup env vars in .envs --- Cargo.lock | 2 +- linkup-cli/Cargo.toml | 2 +- linkup-cli/src/start.rs | 19 ++++++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39e137c..dd3de19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "linkup-cli" -version = "1.0.2" +version = "1.0.3" dependencies = [ "base64 0.22.1", "clap", diff --git a/linkup-cli/Cargo.toml b/linkup-cli/Cargo.toml index ba23862..9e264ec 100644 --- a/linkup-cli/Cargo.toml +++ b/linkup-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "linkup-cli" -version = "1.0.2" +version = "1.0.3" edition = "2021" [[bin]] diff --git a/linkup-cli/src/start.rs b/linkup-cli/src/start.rs index de71016..0291b2e 100644 --- a/linkup-cli/src/start.rs +++ b/linkup-cli/src/start.rs @@ -23,6 +23,7 @@ pub fn start(config_arg: &Option, no_tunnel: bool) -> Result<(), CliErro env_logger::init(); let is_paid = use_paid_tunnels(); let state = load_and_save_state(config_arg, no_tunnel, is_paid)?; + set_linkup_env(state.clone())?; if is_paid { start_paid_tunnel( &RealSystem, @@ -37,6 +38,17 @@ pub fn start(config_arg: &Option, no_tunnel: bool) -> Result<(), CliErro Ok(()) } +fn set_linkup_env(state: LocalState) -> Result<(), CliError> { + // Set env vars to linkup + for service in &state.services { + match &service.directory { + Some(d) => set_service_env(d.clone(), state.linkup.config_path.clone())?, + None => {} + } + } + Ok(()) +} + fn use_paid_tunnels() -> bool { env::var("LINKUP_CLOUDFLARE_ACCOUNT_ID").is_ok() && env::var("LINKUP_CLOUDFLARE_ZONE_ID").is_ok() @@ -102,13 +114,6 @@ fn start_paid_tunnel( fn start_free_tunnel(state: LocalState, no_tunnel: bool) -> Result<(), CliError> { println!("Starting free tunnel"); - // Set env vars to linkup - for service in &state.services { - match &service.directory { - Some(d) => set_service_env(d.clone(), state.linkup.config_path.clone())?, - None => {} - } - } if no_tunnel && !linkup_file_path(LINKUP_LOCALDNS_INSTALL).exists() { println!("Run `linkup local-dns install` before running without a tunnel");