Skip to content

Commit

Permalink
feat(spin): conditionally load runtime config from root (#179)
Browse files Browse the repository at this point in the history
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
  • Loading branch information
kate-goldenring authored Nov 11, 2023
1 parent 47aaea6 commit d90737b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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.

10 changes: 9 additions & 1 deletion containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ use tokio::runtime::Runtime;
use url::Url;

const SPIN_ADDR: &str = "0.0.0.0:80";
/// RUNTIME_CONFIG_PATH specifies the expected location and name of the runtime
/// config for a Spin application. The runtime config should be loaded into the
/// root `/` of the container.
const RUNTIME_CONFIG_PATH: &str = "/runtime-config.toml";

#[derive(Clone, Default)]
pub struct SpinEngine;
Expand Down Expand Up @@ -145,7 +149,11 @@ impl SpinEngine {

// Build trigger config
let loader = loader::TriggerLoader::new(working_dir.clone(), true);
let runtime_config = RuntimeConfig::new(PathBuf::from("/").into());
let mut runtime_config = RuntimeConfig::new(PathBuf::from("/").into());
// Load in runtime config if one exists at expected location
if Path::new(RUNTIME_CONFIG_PATH).exists() {
runtime_config.merge_config_file(RUNTIME_CONFIG_PATH);
}
let mut builder = TriggerExecutorBuilder::new(loader);
builder
.hooks(StdioTriggerHook {})
Expand Down

0 comments on commit d90737b

Please sign in to comment.