Skip to content

Commit

Permalink
fix: set linkup env vars in .envs
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottea98 committed Jun 10, 2024
1 parent 00f9f2c commit 58f4937
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion linkup-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkup-cli"
version = "1.0.2"
version = "1.0.3"
edition = "2021"

[[bin]]
Expand Down
19 changes: 12 additions & 7 deletions linkup-cli/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn start(config_arg: &Option<String>, 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,
Expand All @@ -37,6 +38,17 @@ pub fn start(config_arg: &Option<String>, 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()
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 58f4937

Please sign in to comment.