Skip to content

Commit

Permalink
Merge pull request #391 from stakwork/feat/add-swarm-number-to-jarvis
Browse files Browse the repository at this point in the history
chore: add swarm number to jarvis
  • Loading branch information
Evanfeenstra authored Nov 12, 2024
2 parents 638a155 + 38e0e9c commit 6a0da73
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/images/boltwall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use crate::config::Node;
use crate::conn::lnd::utils::{dl_cert_to_base64, dl_macaroon};
use crate::images::lnd::to_lnd_network;
use crate::secrets;
use crate::utils::{domain, exposed_ports, getenv, host_config, volume_string};
use crate::utils::{
domain, exposed_ports, extract_swarm_number, getenv, host_config, volume_string,
};
use anyhow::{Context, Result};
use async_trait::async_trait;
use bollard::container::Config;
Expand Down Expand Up @@ -210,7 +212,11 @@ fn boltwall(
}

match getenv("HOST") {
Ok(host) => env.push(format!("SWARM_UI=https://app.{}", host)),
Ok(host) => {
env.push(format!("SWARM_UI=https://app.{}", host));
let swarm_number = extract_swarm_number(host);
env.push(format!("SWARM_NUMBER={}", swarm_number));
}
Err(err) => {
log::error!("Error geting env host: {}", err.to_string())
}
Expand Down
8 changes: 7 additions & 1 deletion src/images/jarvis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{boltwall::BoltwallImage, elastic::ElasticImage, neo4j::Neo4jImage, *};
use crate::config::Node;
use crate::utils::{domain, exposed_ports, getenv, host_config};
use crate::utils::{domain, exposed_ports, extract_swarm_number, getenv, host_config};
use anyhow::{Context, Result};
use async_trait::async_trait;
use bollard::container::Config;
Expand Down Expand Up @@ -113,6 +113,12 @@ fn jarvis(
if let Ok(stakwork_key) = getenv("STAKWORK_ADD_NODE_TOKEN") {
env.push(format!("STAKWORK_ADD_NODE_TOKEN={}", stakwork_key));
}

if let Ok(swarm_host) = getenv("HOST") {
let swarm_number = extract_swarm_number(swarm_host);
env.push(format!("SWARM_NUMBER={}", swarm_number));
}

if let Ok(stakwork_radar_token) = getenv("STAKWORK_RADAR_REQUEST_TOKEN") {
env.push(format!("RADAR_REQUEST_TOKEN={}", stakwork_radar_token));
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,7 @@ pub fn getenv(envname: &str) -> Result<String> {
Err(anyhow!("{} is empty", envname))
}
}

pub fn extract_swarm_number(host: String) -> String {
host.chars().filter(|c| c.is_numeric()).collect()
}

0 comments on commit 6a0da73

Please sign in to comment.