From d90737ba8b079156b9e7d98436c9f91bc3538149 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Sat, 11 Nov 2023 16:31:03 -0600 Subject: [PATCH] feat(spin): conditionally load runtime config from root (#179) Signed-off-by: Kate Goldenring --- Cargo.lock | 2 +- containerd-shim-spin/src/engine.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43ec825..21c1c97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ dependencies = [ [[package]] name = "containerd-wasm-shims-tests" -version = "0.9.2" +version = "0.9.3" dependencies = [ "anyhow", "curl", diff --git a/containerd-shim-spin/src/engine.rs b/containerd-shim-spin/src/engine.rs index 65ff799..319f0d1 100644 --- a/containerd-shim-spin/src/engine.rs +++ b/containerd-shim-spin/src/engine.rs @@ -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; @@ -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 {})