|
@@ -42,8 +42,7 @@ use std::collections::HashSet;
|
|
|
/// 2. `./config.toml` in cwd
|
|
/// 2. `./config.toml` in cwd
|
|
|
/// 3. `<default_config_dir>/config.toml`
|
|
/// 3. `<default_config_dir>/config.toml`
|
|
|
///
|
|
///
|
|
|
-/// Returns an error if nothing is found, with a hint pointing the user
|
|
|
|
|
-/// to copy the example config to one of the two paths.
|
|
|
|
|
|
|
+/// Returns an error if nothing is found (hint: copy the example config).
|
|
|
fn resolve_config_path(cli_config: &str) -> std::path::PathBuf {
|
|
fn resolve_config_path(cli_config: &str) -> std::path::PathBuf {
|
|
|
use std::path::PathBuf;
|
|
use std::path::PathBuf;
|
|
|
let explicit = PathBuf::from(cli_config);
|
|
let explicit = PathBuf::from(cli_config);
|
|
@@ -86,7 +85,8 @@ async fn main() -> Result<()> {
|
|
|
|
|
|
|
|
let config_path = resolve_config_path(&cli.config);
|
|
let config_path = resolve_config_path(&cli.config);
|
|
|
let raw_config = tokio::fs::read_to_string(&config_path).await?;
|
|
let raw_config = tokio::fs::read_to_string(&config_path).await?;
|
|
|
- let config: Config = toml::from_str(&raw_config)?;
|
|
|
|
|
|
|
+ let mut config: Config = toml::from_str(&raw_config)?;
|
|
|
|
|
+ crate::config::merge_cluster_sources(&mut config).await?;
|
|
|
let dry_run = cli.dry_run;
|
|
let dry_run = cli.dry_run;
|
|
|
|
|
|
|
|
match cli.command {
|
|
match cli.command {
|
|
@@ -221,7 +221,7 @@ async fn handle_serve(
|
|
|
follow: bool,
|
|
follow: bool,
|
|
|
dry_run: bool,
|
|
dry_run: bool,
|
|
|
) -> Result<()> {
|
|
) -> Result<()> {
|
|
|
- let recipe_obj = load_recipe(recipe).await?;
|
|
|
|
|
|
|
+ let recipe_obj = load_recipe(recipe, &config.recipe_sources).await?;
|
|
|
match recipe_obj.deploy {
|
|
match recipe_obj.deploy {
|
|
|
DeployTarget::Docker => {
|
|
DeployTarget::Docker => {
|
|
|
let cluster = docker::serve(config, recipe, cluster, node.as_deref(), opts).await?;
|
|
let cluster = docker::serve(config, recipe, cluster, node.as_deref(), opts).await?;
|
|
@@ -282,7 +282,7 @@ async fn handle_build_cmd(
|
|
|
force_build: bool,
|
|
force_build: bool,
|
|
|
dry_run: bool,
|
|
dry_run: bool,
|
|
|
) -> Result<()> {
|
|
) -> Result<()> {
|
|
|
- let recipe_obj = crate::config::load_recipe(recipe).await?;
|
|
|
|
|
|
|
+ let recipe_obj = crate::config::load_recipe(recipe, &config.recipe_sources).await?;
|
|
|
let cluster = crate::config::resolve_build_cluster(config, cluster, build_node)?;
|
|
let cluster = crate::config::resolve_build_cluster(config, cluster, build_node)?;
|
|
|
let opts = docker::ServeOpts {
|
|
let opts = docker::ServeOpts {
|
|
|
keep: false,
|
|
keep: false,
|
|
@@ -376,7 +376,7 @@ async fn handle_stop(
|
|
|
// Run recipe `after_stop` hooks (e.g. restore_dgx_services) on the
|
|
// Run recipe `after_stop` hooks (e.g. restore_dgx_services) on the
|
|
|
// nodes that were actually stopped. Best-effort against the loaded
|
|
// nodes that were actually stopped. Best-effort against the loaded
|
|
|
// recipe; if the recipe file is unavailable, skip silently.
|
|
// recipe; if the recipe file is unavailable, skip silently.
|
|
|
- if let Ok(recipe) = crate::config::load_recipe(recipe_name).await {
|
|
|
|
|
|
|
+ if let Ok(recipe) = crate::config::load_recipe(recipe_name, &config.recipe_sources).await {
|
|
|
crate::after_stop::run(config, &stopped_cluster, &recipe, dry_run).await?;
|
|
crate::after_stop::run(config, &stopped_cluster, &recipe, dry_run).await?;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -485,7 +485,7 @@ async fn resolve_cluster_for_op(
|
|
|
cluster_name: &str,
|
|
cluster_name: &str,
|
|
|
) -> Result<Cluster> {
|
|
) -> Result<Cluster> {
|
|
|
if cluster_name != "auto" {
|
|
if cluster_name != "auto" {
|
|
|
- let recipe = load_recipe(recipe_name).await?;
|
|
|
|
|
|
|
+ let recipe = load_recipe(recipe_name, &config.recipe_sources).await?;
|
|
|
let (cluster, _) = resolve_cluster(config, &recipe, cluster_name, &HashSet::new())?;
|
|
let (cluster, _) = resolve_cluster(config, &recipe, cluster_name, &HashSet::new())?;
|
|
|
return Ok(cluster);
|
|
return Ok(cluster);
|
|
|
}
|
|
}
|
|
@@ -494,7 +494,7 @@ async fn resolve_cluster_for_op(
|
|
|
return Ok(c.clone());
|
|
return Ok(c.clone());
|
|
|
}
|
|
}
|
|
|
// Fall back to config-based auto (dry-run / containers not running)
|
|
// Fall back to config-based auto (dry-run / containers not running)
|
|
|
- let recipe = load_recipe(recipe_name).await?;
|
|
|
|
|
|
|
+ let recipe = load_recipe(recipe_name, &config.recipe_sources).await?;
|
|
|
let (cluster, _) = resolve_cluster(config, &recipe, "auto", &HashSet::new())?;
|
|
let (cluster, _) = resolve_cluster(config, &recipe, "auto", &HashSet::new())?;
|
|
|
Ok(cluster)
|
|
Ok(cluster)
|
|
|
}
|
|
}
|