Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set linkup env vars in .envs #99

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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