Skip to content

Commit

Permalink
feat: allow config path to be configured via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaiahReid committed Sep 22, 2023
1 parent ddb9ca2 commit a5ba907
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use stacks_devnet_api::routes::{
handle_new_devnet, handle_try_proxy_service, API_PATH,
};
use stacks_devnet_api::{Context, StacksDevnetApiK8sManager};
use std::env;
use std::{convert::Infallible, net::SocketAddr};

#[tokio::main]
Expand All @@ -24,12 +25,17 @@ async fn main() {
tracer: false,
};
let k8s_manager = StacksDevnetApiK8sManager::default(&ctx).await;
let config_path = if cfg!(debug_assertions) {
"./Config.toml"
} else {
"/etc/config/Config.toml"
let config_path = match env::var("CONFIG_PATH") {
Ok(path) => path,
Err(_) => {
if cfg!(debug_assertions) {
"./Config.toml".into()
} else {
"/etc/config/Config.toml".into()
}
}
};
let config = ApiConfig::from_path(config_path);
let config = ApiConfig::from_path(&config_path);

let make_svc = make_service_fn(|_| {
let k8s_manager = k8s_manager.clone();
Expand Down

0 comments on commit a5ba907

Please sign in to comment.