diff --git a/Cargo.lock b/Cargo.lock index 2bc6313f61f1..2b4e75f9a86c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3773,10 +3773,10 @@ dependencies = [ "wasmtime-explorer", "wasmtime-test-macros", "wasmtime-wasi", + "wasmtime-wasi-config", "wasmtime-wasi-http", "wasmtime-wasi-keyvalue", "wasmtime-wasi-nn", - "wasmtime-wasi-runtime-config", "wasmtime-wasi-threads", "wasmtime-wast", "wast 219.0.0", @@ -4050,6 +4050,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "wasmtime-wasi-config" +version = "27.0.0" +dependencies = [ + "anyhow", + "test-programs-artifacts", + "tokio", + "wasmtime", + "wasmtime-wasi", +] + [[package]] name = "wasmtime-wasi-http" version = "27.0.0" @@ -4107,17 +4118,6 @@ dependencies = [ "windows", ] -[[package]] -name = "wasmtime-wasi-runtime-config" -version = "27.0.0" -dependencies = [ - "anyhow", - "test-programs-artifacts", - "tokio", - "wasmtime", - "wasmtime-wasi", -] - [[package]] name = "wasmtime-wasi-threads" version = "27.0.0" diff --git a/Cargo.toml b/Cargo.toml index d80e7f55b141..e628b0ad00c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ wasmtime-wast = { workspace = true, optional = true } wasi-common = { workspace = true, default-features = true, features = ["exit", "tokio"], optional = true } wasmtime-wasi = { workspace = true, default-features = true, optional = true } wasmtime-wasi-nn = { workspace = true, optional = true } -wasmtime-wasi-runtime-config = { workspace = true, optional = true } +wasmtime-wasi-config = { workspace = true, optional = true } wasmtime-wasi-keyvalue = { workspace = true, optional = true } wasmtime-wasi-threads = { workspace = true, optional = true } wasmtime-wasi-http = { workspace = true, optional = true } @@ -210,7 +210,7 @@ wasmtime-wast = { path = "crates/wast", version = "=27.0.0" } wasmtime-wasi = { path = "crates/wasi", version = "27.0.0", default-features = false } wasmtime-wasi-http = { path = "crates/wasi-http", version = "=27.0.0", default-features = false } wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "27.0.0" } -wasmtime-wasi-runtime-config = { path = "crates/wasi-runtime-config", version = "27.0.0" } +wasmtime-wasi-config = { path = "crates/wasi-config", version = "27.0.0" } wasmtime-wasi-keyvalue = { path = "crates/wasi-keyvalue", version = "27.0.0" } wasmtime-wasi-threads = { path = "crates/wasi-threads", version = "27.0.0" } wasmtime-component-util = { path = "crates/component-util", version = "=27.0.0" } @@ -375,7 +375,7 @@ default = [ "wasi-nn", "wasi-threads", "wasi-http", - "wasi-runtime-config", + "wasi-config", "wasi-keyvalue", # Most features of Wasmtime are enabled by default. @@ -424,7 +424,7 @@ disable-logging = ["log/max_level_off", "tracing/max_level_off"] wasi-nn = ["dep:wasmtime-wasi-nn"] wasi-threads = ["dep:wasmtime-wasi-threads", "threads"] wasi-http = ["component-model", "dep:wasmtime-wasi-http", "dep:tokio", "dep:hyper"] -wasi-runtime-config = ["dep:wasmtime-wasi-runtime-config"] +wasi-config = ["dep:wasmtime-wasi-config"] wasi-keyvalue = ["dep:wasmtime-wasi-keyvalue"] pooling-allocator = ["wasmtime/pooling-allocator", "wasmtime-cli-flags/pooling-allocator"] component-model = [ diff --git a/ci/vendor-wit.sh b/ci/vendor-wit.sh index 1e83d720bc4e..80b276f8e884 100755 --- a/ci/vendor-wit.sh +++ b/ci/vendor-wit.sh @@ -55,7 +55,7 @@ make_vendor "wasi-http" " http@v0.2.2 " -make_vendor "wasi-runtime-config" "runtime-config@c667fe6" +make_vendor "wasi-config" "config@f4d699b" make_vendor "wasi-keyvalue" "keyvalue@219ea36" diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index 015a9b678009..aa2383ecd542 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -305,8 +305,8 @@ wasmtime_option_group! { pub threads: Option, /// Enable support for WASI HTTP API (experimental) pub http: Option, - /// Enable support for WASI runtime config API (experimental) - pub runtime_config: Option, + /// Enable support for WASI config API (experimental) + pub config: Option, /// Enable support for WASI key-value API (experimental) pub keyvalue: Option, /// Inherit environment variables and file descriptors following the @@ -346,8 +346,8 @@ wasmtime_option_group! { /// /// This option can be further overwritten with `--env` flags. pub inherit_env: Option, - /// Pass a wasi runtime config variable to the program. - pub runtime_config_var: Vec, + /// Pass a wasi config variable to the program. + pub config_var: Vec, /// Preset data for the In-Memory provider of WASI key-value API. pub keyvalue_in_memory_data: Vec, } diff --git a/crates/test-programs/artifacts/build.rs b/crates/test-programs/artifacts/build.rs index 018b5cce995b..f5966a67ea5e 100644 --- a/crates/test-programs/artifacts/build.rs +++ b/crates/test-programs/artifacts/build.rs @@ -76,7 +76,7 @@ fn build_and_generate_tests() { s if s.starts_with("nn_") => "nn", s if s.starts_with("piped_") => "piped", s if s.starts_with("dwarf_") => "dwarf", - s if s.starts_with("runtime_config_") => "runtime_config", + s if s.starts_with("config_") => "config", s if s.starts_with("keyvalue_") => "keyvalue", // If you're reading this because you hit this panic, either add it // to a test suite above or add a new "suite". The purpose of the diff --git a/crates/test-programs/src/bin/cli_serve_runtime_config.rs b/crates/test-programs/src/bin/cli_serve_config.rs similarity index 90% rename from crates/test-programs/src/bin/cli_serve_runtime_config.rs rename to crates/test-programs/src/bin/cli_serve_config.rs index d56227dc4039..a302660de3fe 100644 --- a/crates/test-programs/src/bin/cli_serve_runtime_config.rs +++ b/crates/test-programs/src/bin/cli_serve_config.rs @@ -1,6 +1,6 @@ use test_programs::proxy; use test_programs::wasi::{ - config::runtime, + config::store, http::types::{Fields, IncomingRequest, OutgoingBody, OutgoingResponse, ResponseOutparam}, }; @@ -17,7 +17,7 @@ impl proxy::exports::wasi::http::incoming_handler::Guest for T { ResponseOutparam::set(outparam, Ok(resp)); let out = body.write().expect("outgoing stream"); - let config = runtime::get("hello").unwrap().unwrap(); + let config = store::get("hello").unwrap().unwrap(); out.blocking_write_and_flush(config.as_bytes()) .expect("writing response"); diff --git a/crates/test-programs/src/bin/config_get.rs b/crates/test-programs/src/bin/config_get.rs new file mode 100644 index 000000000000..302b9b136a0c --- /dev/null +++ b/crates/test-programs/src/bin/config_get.rs @@ -0,0 +1,8 @@ +use test_programs::wasi::config::store; + +fn main() { + let v = store::get("hello").unwrap().unwrap(); + assert_eq!(v, "world"); + let config = store::get_all().unwrap(); + assert_eq!(config, [("hello".to_string(), "world".to_string())]) +} diff --git a/crates/test-programs/src/bin/runtime_config_get.rs b/crates/test-programs/src/bin/runtime_config_get.rs deleted file mode 100644 index e3013cdb2236..000000000000 --- a/crates/test-programs/src/bin/runtime_config_get.rs +++ /dev/null @@ -1,8 +0,0 @@ -use test_programs::wasi::config::runtime; - -fn main() { - let v = runtime::get("hello").unwrap().unwrap(); - assert_eq!(v, "world"); - let config = runtime::get_all().unwrap(); - assert_eq!(config, [("hello".to_string(), "world".to_string())]) -} diff --git a/crates/test-programs/src/lib.rs b/crates/test-programs/src/lib.rs index 57e81dda146d..bdd9f1cba609 100644 --- a/crates/test-programs/src/lib.rs +++ b/crates/test-programs/src/lib.rs @@ -16,7 +16,7 @@ wit_bindgen::generate!({ ", path: [ "../wasi-http/wit", - "../wasi-runtime-config/wit", + "../wasi-config/wit", "../wasi-keyvalue/wit", ], world: "wasmtime:test/test", diff --git a/crates/wasi-runtime-config/Cargo.toml b/crates/wasi-config/Cargo.toml similarity index 82% rename from crates/wasi-runtime-config/Cargo.toml rename to crates/wasi-config/Cargo.toml index 03df5d5bbcdd..81bd61ef7184 100644 --- a/crates/wasi-runtime-config/Cargo.toml +++ b/crates/wasi-config/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "wasmtime-wasi-runtime-config" +name = "wasmtime-wasi-config" version.workspace = true authors.workspace = true edition.workspace = true rust-version.workspace = true repository = "https://github.com/bytecodealliance/wasmtime" license = "Apache-2.0 WITH LLVM-exception" -description = "Wasmtime implementation of the wasi-runtime-config API" +description = "Wasmtime implementation of the wasi-config API" [lints] workspace = true diff --git a/crates/wasi-runtime-config/src/lib.rs b/crates/wasi-config/src/lib.rs similarity index 63% rename from crates/wasi-runtime-config/src/lib.rs rename to crates/wasi-config/src/lib.rs index 615e7b873fa5..8d6906dfde47 100644 --- a/crates/wasi-runtime-config/src/lib.rs +++ b/crates/wasi-config/src/lib.rs @@ -1,8 +1,8 @@ -//! # Wasmtime's [wasi-runtime-config] Implementation +//! # Wasmtime's [wasi-config] Implementation //! -//! This crate provides a Wasmtime host implementation of the [wasi-runtime-config] +//! This crate provides a Wasmtime host implementation of the [wasi-config] //! API. With this crate, the runtime can run components that call APIs in -//! [wasi-runtime-config] and provide configuration variables for the component. +//! [wasi-config] and provide configuration variables for the component. //! //! # Examples //! @@ -18,7 +18,7 @@ //! Config, Engine, Result, Store, //! }; //! use wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiView}; -//! use wasmtime_wasi_runtime_config::{WasiRuntimeConfig, WasiRuntimeConfigVariables}; +//! use wasmtime_wasi_config::{WasiConfig, WasiConfigVariables}; //! //! #[tokio::main] //! async fn main() -> Result<()> { @@ -29,7 +29,7 @@ //! let mut store = Store::new(&engine, Ctx { //! table: ResourceTable::new(), //! wasi_ctx: WasiCtxBuilder::new().build(), -//! wasi_runtime_config_vars: WasiRuntimeConfigVariables::from_iter(vec![ +//! wasi_config_vars: WasiConfigVariables::from_iter(vec![ //! ("config_key1", "value1"), //! ("config_key2", "value2"), //! ]), @@ -37,9 +37,9 @@ //! //! let mut linker = Linker::::new(&engine); //! wasmtime_wasi::add_to_linker_async(&mut linker)?; -//! // add `wasi-runtime-config` world's interfaces to the linker -//! wasmtime_wasi_runtime_config::add_to_linker(&mut linker, |h: &mut Ctx| { -//! WasiRuntimeConfig::from(&h.wasi_runtime_config_vars) +//! // add `wasi-config` world's interfaces to the linker +//! wasmtime_wasi_config::add_to_linker(&mut linker, |h: &mut Ctx| { +//! WasiConfig::from(&h.wasi_config_vars) //! })?; //! //! // ... use `linker` to instantiate within `store` ... @@ -50,7 +50,7 @@ //! struct Ctx { //! table: ResourceTable, //! wasi_ctx: WasiCtx, -//! wasi_runtime_config_vars: WasiRuntimeConfigVariables, +//! wasi_config_vars: WasiConfigVariables, //! } //! //! impl WasiView for Ctx { @@ -59,7 +59,7 @@ //! } //! ``` //! -//! [wasi-runtime-config]: https://github.com/WebAssembly/wasi-runtime-config +//! [wasi-config]: https://github.com/WebAssembly/wasi-config //! [wasi:cli]: https://docs.rs/wasmtime-wasi/latest //! [wasi:http]: https://docs.rs/wasmtime-wasi-http/latest @@ -75,13 +75,13 @@ mod gen_ { trappable_imports: true, }); } -use self::gen_::wasi::config::runtime as generated; +use self::gen_::wasi::config::store as generated; -/// Capture the state necessary for use in the `wasi-runtime-config` API implementation. +/// Capture the state necessary for use in the `wasi-config` API implementation. #[derive(Default)] -pub struct WasiRuntimeConfigVariables(HashMap); +pub struct WasiConfigVariables(HashMap); -impl> FromIterator<(S, S)> for WasiRuntimeConfigVariables { +impl> FromIterator<(S, S)> for WasiConfigVariables { fn from_iter>(iter: I) -> Self { Self( iter.into_iter() @@ -91,7 +91,7 @@ impl> FromIterator<(S, S)> for WasiRuntimeConfigVariables { } } -impl WasiRuntimeConfigVariables { +impl WasiConfigVariables { /// Create a new runtime configuration. pub fn new() -> Self { Default::default() @@ -104,30 +104,30 @@ impl WasiRuntimeConfigVariables { } } -/// A wrapper capturing the needed internal `wasi-runtime-config` state. -pub struct WasiRuntimeConfig<'a> { - vars: &'a WasiRuntimeConfigVariables, +/// A wrapper capturing the needed internal `wasi-config` state. +pub struct WasiConfig<'a> { + vars: &'a WasiConfigVariables, } -impl<'a> From<&'a WasiRuntimeConfigVariables> for WasiRuntimeConfig<'a> { - fn from(vars: &'a WasiRuntimeConfigVariables) -> Self { +impl<'a> From<&'a WasiConfigVariables> for WasiConfig<'a> { + fn from(vars: &'a WasiConfigVariables) -> Self { Self { vars } } } -impl<'a> WasiRuntimeConfig<'a> { - /// Create a new view into the `wasi-runtime-config` state. - pub fn new(vars: &'a WasiRuntimeConfigVariables) -> Self { +impl<'a> WasiConfig<'a> { + /// Create a new view into the `wasi-config` state. + pub fn new(vars: &'a WasiConfigVariables) -> Self { Self { vars } } } -impl generated::Host for WasiRuntimeConfig<'_> { - fn get(&mut self, key: String) -> Result, generated::ConfigError>> { +impl generated::Host for WasiConfig<'_> { + fn get(&mut self, key: String) -> Result, generated::Error>> { Ok(Ok(self.vars.0.get(&key).map(|s| s.to_owned()))) } - fn get_all(&mut self) -> Result, generated::ConfigError>> { + fn get_all(&mut self) -> Result, generated::Error>> { Ok(Ok(self .vars .0 @@ -137,10 +137,10 @@ impl generated::Host for WasiRuntimeConfig<'_> { } } -/// Add all the `wasi-runtime-config` world's interfaces to a [`wasmtime::component::Linker`]. +/// Add all the `wasi-config` world's interfaces to a [`wasmtime::component::Linker`]. pub fn add_to_linker( l: &mut wasmtime::component::Linker, - f: impl Fn(&mut T) -> WasiRuntimeConfig<'_> + Send + Sync + Copy + 'static, + f: impl Fn(&mut T) -> WasiConfig<'_> + Send + Sync + Copy + 'static, ) -> Result<()> { generated::add_to_linker_get_host(l, f)?; Ok(()) diff --git a/crates/wasi-runtime-config/tests/main.rs b/crates/wasi-config/tests/main.rs similarity index 68% rename from crates/wasi-runtime-config/tests/main.rs rename to crates/wasi-config/tests/main.rs index 5c07bc9e3fc7..544bc03cd667 100644 --- a/crates/wasi-runtime-config/tests/main.rs +++ b/crates/wasi-config/tests/main.rs @@ -1,16 +1,16 @@ use anyhow::{anyhow, Result}; -use test_programs_artifacts::{foreach_runtime_config, RUNTIME_CONFIG_GET_COMPONENT}; +use test_programs_artifacts::{foreach_config, CONFIG_GET_COMPONENT}; use wasmtime::{ component::{Component, Linker, ResourceTable}, Store, }; use wasmtime_wasi::{add_to_linker_async, bindings::Command, WasiCtx, WasiCtxBuilder, WasiView}; -use wasmtime_wasi_runtime_config::{WasiRuntimeConfig, WasiRuntimeConfigVariables}; +use wasmtime_wasi_config::{WasiConfig, WasiConfigVariables}; struct Ctx { table: ResourceTable, wasi_ctx: WasiCtx, - wasi_runtime_config_vars: WasiRuntimeConfigVariables, + wasi_config_vars: WasiConfigVariables, } impl WasiView for Ctx { @@ -32,8 +32,8 @@ async fn run_wasi(path: &str, ctx: Ctx) -> Result<()> { let mut linker = Linker::new(&engine); add_to_linker_async(&mut linker)?; - wasmtime_wasi_runtime_config::add_to_linker(&mut linker, |h: &mut Ctx| { - WasiRuntimeConfig::from(&h.wasi_runtime_config_vars) + wasmtime_wasi_config::add_to_linker(&mut linker, |h: &mut Ctx| { + WasiConfig::from(&h.wasi_config_vars) })?; let command = Command::instantiate_async(&mut store, &component, &linker).await?; @@ -51,18 +51,16 @@ macro_rules! assert_test_exists { }; } -foreach_runtime_config!(assert_test_exists); +foreach_config!(assert_test_exists); #[tokio::test(flavor = "multi_thread")] -async fn runtime_config_get() -> Result<()> { +async fn config_get() -> Result<()> { run_wasi( - RUNTIME_CONFIG_GET_COMPONENT, + CONFIG_GET_COMPONENT, Ctx { table: ResourceTable::new(), wasi_ctx: WasiCtxBuilder::new().build(), - wasi_runtime_config_vars: WasiRuntimeConfigVariables::from_iter(vec![( - "hello", "world", - )]), + wasi_config_vars: WasiConfigVariables::from_iter(vec![("hello", "world")]), }, ) .await diff --git a/crates/wasi-runtime-config/wit/deps/runtime-config/runtime_config.wit b/crates/wasi-config/wit/deps/config/store.wit similarity index 60% rename from crates/wasi-runtime-config/wit/deps/runtime-config/runtime_config.wit rename to crates/wasi-config/wit/deps/config/store.wit index 29d53b1acd30..794379a754b1 100644 --- a/crates/wasi-runtime-config/wit/deps/runtime-config/runtime_config.wit +++ b/crates/wasi-config/wit/deps/config/store.wit @@ -1,6 +1,6 @@ -interface runtime { - /// An error type that encapsulates the different errors that can occur fetching config - variant config-error { +interface store { + /// An error type that encapsulates the different errors that can occur fetching configuration values. + variant error { /// This indicates an error from an "upstream" config source. /// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), /// the error message is a string. @@ -14,12 +14,17 @@ interface runtime { io(string), } - /// Gets a single opaque config value set at the given key if it exists + /// Gets a configuration value of type `string` associated with the `key`. + /// + /// The value is returned as an `option`. If the key is not found, + /// `Ok(none)` is returned. If an error occurs, an `Err(error)` is returned. get: func( /// A string key to fetch key: string - ) -> result, config-error>; + ) -> result, error>; - /// Gets a list of all set config data - get-all: func() -> result>, config-error>; + /// Gets a list of configuration key-value pairs of type `string`. + /// + /// If an error occurs, an `Err(error)` is returned. + get-all: func() -> result>, error>; } diff --git a/crates/wasi-config/wit/deps/config/world.wit b/crates/wasi-config/wit/deps/config/world.wit new file mode 100644 index 000000000000..f92f080a5768 --- /dev/null +++ b/crates/wasi-config/wit/deps/config/world.wit @@ -0,0 +1,6 @@ +package wasi:config@0.2.0-draft; + +world imports { + /// The interface for wasi:config/store + import store; +} \ No newline at end of file diff --git a/crates/wasi-runtime-config/wit/world.wit b/crates/wasi-config/wit/world.wit similarity index 100% rename from crates/wasi-runtime-config/wit/world.wit rename to crates/wasi-config/wit/world.wit diff --git a/crates/wasi-keyvalue/src/lib.rs b/crates/wasi-keyvalue/src/lib.rs index c45e501f8074..4d53a9acf20b 100644 --- a/crates/wasi-keyvalue/src/lib.rs +++ b/crates/wasi-keyvalue/src/lib.rs @@ -37,7 +37,7 @@ //! //! let mut linker = Linker::::new(&engine); //! wasmtime_wasi::add_to_linker_async(&mut linker)?; -//! // add `wasi-runtime-config` world's interfaces to the linker +//! // add `wasi-keyvalue` world's interfaces to the linker //! wasmtime_wasi_keyvalue::add_to_linker(&mut linker, |h: &mut Ctx| { //! WasiKeyValue::new(&h.wasi_keyvalue_ctx, &mut h.table) //! })?; diff --git a/crates/wasi-runtime-config/wit/deps/runtime-config/world.wit b/crates/wasi-runtime-config/wit/deps/runtime-config/world.wit deleted file mode 100644 index 378c4a77954c..000000000000 --- a/crates/wasi-runtime-config/wit/deps/runtime-config/world.wit +++ /dev/null @@ -1,6 +0,0 @@ -package wasi:config@0.2.0-draft; - -world imports { - /// The runtime interface for config - import runtime; -} \ No newline at end of file diff --git a/docs/stability-tiers.md b/docs/stability-tiers.md index 7fedfa984e03..42886dc71d3f 100644 --- a/docs/stability-tiers.md +++ b/docs/stability-tiers.md @@ -98,14 +98,14 @@ For explanations of what each tier means see below. | WebAssembly Proposal | [`gc`] | Complete implementation | | WASI Proposal | [`wasi-nn`] | More expansive CI testing | | WASI Proposal | [`wasi-threads`] | More CI, unstable proposal | -| WASI Proposal | [`wasi-runtime-config`] | unstable proposal | +| WASI Proposal | [`wasi-config`] | unstable proposal | | WASI Proposal | [`wasi-keyvalue`] | unstable proposal | | *misc* | Non-Wasmtime Cranelift usage [^1] | CI testing, full-time maintainer | | *misc* | DWARF debugging [^2] | CI testing, full-time maintainer, improved quality | [`wasi-nn`]: https://github.com/WebAssembly/wasi-nn [`wasi-threads`]: https://github.com/WebAssembly/wasi-threads -[`wasi-runtime-config`]: https://github.com/WebAssembly/wasi-runtime-config +[`wasi-config`]: https://github.com/WebAssembly/wasi-config [`wasi-keyvalue`]: https://github.com/WebAssembly/wasi-keyvalue [`gc`]: https://github.com/WebAssembly/gc diff --git a/scripts/publish.rs b/scripts/publish.rs index df0bb1248cf4..3a3542086601 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -67,7 +67,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[ "wasmtime-wasi", "wasmtime-wasi-http", "wasmtime-wasi-nn", - "wasmtime-wasi-runtime-config", + "wasmtime-wasi-config", "wasmtime-wasi-keyvalue", "wasmtime-wasi-threads", "wasmtime-wast", @@ -88,7 +88,7 @@ const PUBLIC_CRATES: &[&str] = &[ "wasmtime", "wasmtime-wasi", "wasmtime-wasi-nn", - "wasmtime-wasi-runtime-config", + "wasmtime-wasi-config", "wasmtime-wasi-keyvalue", "wasmtime-wasi-threads", "wasmtime-cli", diff --git a/src/commands/run.rs b/src/commands/run.rs index e8c731c32093..c9abf273947a 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -23,12 +23,12 @@ use wasmtime_wasi_nn::wit::WasiNnView; #[cfg(feature = "wasi-threads")] use wasmtime_wasi_threads::WasiThreadsCtx; +#[cfg(feature = "wasi-config")] +use wasmtime_wasi_config::{WasiConfig, WasiConfigVariables}; #[cfg(feature = "wasi-http")] use wasmtime_wasi_http::WasiHttpCtx; #[cfg(feature = "wasi-keyvalue")] use wasmtime_wasi_keyvalue::{WasiKeyValue, WasiKeyValueCtx, WasiKeyValueCtxBuilder}; -#[cfg(feature = "wasi-runtime-config")] -use wasmtime_wasi_runtime_config::{WasiRuntimeConfig, WasiRuntimeConfigVariables}; fn parse_preloads(s: &str) -> Result<(String, PathBuf)> { let parts: Vec<&str> = s.splitn(2, '=').collect(); @@ -695,33 +695,33 @@ impl RunCommand { } } - if self.run.common.wasi.runtime_config == Some(true) { - #[cfg(not(feature = "wasi-runtime-config"))] + if self.run.common.wasi.config == Some(true) { + #[cfg(not(feature = "wasi-config"))] { - bail!("Cannot enable wasi-runtime-config when the binary is not compiled with this feature."); + bail!( + "Cannot enable wasi-config when the binary is not compiled with this feature." + ); } - #[cfg(all(feature = "wasi-runtime-config", feature = "component-model"))] + #[cfg(all(feature = "wasi-config", feature = "component-model"))] { match linker { CliLinker::Core(_) => { - bail!("Cannot enable wasi-runtime-config for core wasm modules"); + bail!("Cannot enable wasi-config for core wasm modules"); } CliLinker::Component(linker) => { - let vars = WasiRuntimeConfigVariables::from_iter( + let vars = WasiConfigVariables::from_iter( self.run .common .wasi - .runtime_config_var + .config_var .iter() .map(|v| (v.key.clone(), v.value.clone())), ); - wasmtime_wasi_runtime_config::add_to_linker(linker, |h| { - WasiRuntimeConfig::new( - Arc::get_mut(h.wasi_runtime_config.as_mut().unwrap()).unwrap(), - ) + wasmtime_wasi_config::add_to_linker(linker, |h| { + WasiConfig::new(Arc::get_mut(h.wasi_config.as_mut().unwrap()).unwrap()) })?; - store.data_mut().wasi_runtime_config = Some(Arc::new(vars)); + store.data_mut().wasi_config = Some(Arc::new(vars)); } } } @@ -911,8 +911,8 @@ struct Host { #[cfg(feature = "profiling")] guest_profiler: Option>, - #[cfg(feature = "wasi-runtime-config")] - wasi_runtime_config: Option>, + #[cfg(feature = "wasi-config")] + wasi_config: Option>, #[cfg(feature = "wasi-keyvalue")] wasi_keyvalue: Option>, } diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 227e49dfcdbd..f3b4643f26ad 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -17,12 +17,12 @@ use wasmtime_wasi_http::bindings::ProxyPre; use wasmtime_wasi_http::io::TokioIo; use wasmtime_wasi_http::{body::HyperOutgoingBody, WasiHttpCtx, WasiHttpView}; +#[cfg(feature = "wasi-config")] +use wasmtime_wasi_config::{WasiConfig, WasiConfigVariables}; #[cfg(feature = "wasi-keyvalue")] use wasmtime_wasi_keyvalue::{WasiKeyValue, WasiKeyValueCtx, WasiKeyValueCtxBuilder}; #[cfg(feature = "wasi-nn")] use wasmtime_wasi_nn::wit::WasiNnCtx; -#[cfg(feature = "wasi-runtime-config")] -use wasmtime_wasi_runtime_config::{WasiRuntimeConfig, WasiRuntimeConfigVariables}; struct Host { table: wasmtime::component::ResourceTable, @@ -34,8 +34,8 @@ struct Host { #[cfg(feature = "wasi-nn")] nn: Option, - #[cfg(feature = "wasi-runtime-config")] - wasi_runtime_config: Option, + #[cfg(feature = "wasi-config")] + wasi_config: Option, #[cfg(feature = "wasi-keyvalue")] wasi_keyvalue: Option, @@ -157,8 +157,8 @@ impl ServeCommand { #[cfg(feature = "wasi-nn")] nn: None, - #[cfg(feature = "wasi-runtime-config")] - wasi_runtime_config: None, + #[cfg(feature = "wasi-config")] + wasi_config: None, #[cfg(feature = "wasi-keyvalue")] wasi_keyvalue: None, }; @@ -179,18 +179,18 @@ impl ServeCommand { } } - if self.run.common.wasi.runtime_config == Some(true) { - #[cfg(feature = "wasi-runtime-config")] + if self.run.common.wasi.config == Some(true) { + #[cfg(feature = "wasi-config")] { - let vars = WasiRuntimeConfigVariables::from_iter( + let vars = WasiConfigVariables::from_iter( self.run .common .wasi - .runtime_config_var + .config_var .iter() .map(|v| (v.key.clone(), v.value.clone())), ); - host.wasi_runtime_config.replace(vars); + host.wasi_config.replace(vars); } } @@ -275,15 +275,15 @@ impl ServeCommand { } } - if self.run.common.wasi.runtime_config == Some(true) { - #[cfg(not(feature = "wasi-runtime-config"))] + if self.run.common.wasi.config == Some(true) { + #[cfg(not(feature = "wasi-config"))] { - bail!("support for wasi-runtime-config was disabled at compile time"); + bail!("support for wasi-config was disabled at compile time"); } - #[cfg(feature = "wasi-runtime-config")] + #[cfg(feature = "wasi-config")] { - wasmtime_wasi_runtime_config::add_to_linker(linker, |h| { - WasiRuntimeConfig::from(h.wasi_runtime_config.as_ref().unwrap()) + wasmtime_wasi_config::add_to_linker(linker, |h| { + WasiConfig::from(h.wasi_config.as_ref().unwrap()) })?; } } diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs index 675c91b94d06..b7ea967c7808 100644 --- a/tests/all/cli_tests.rs +++ b/tests/all/cli_tests.rs @@ -1923,11 +1923,11 @@ stderr [1] :: after empty } #[tokio::test] - async fn cli_serve_runtime_config() -> Result<()> { - let server = WasmtimeServe::new(CLI_SERVE_RUNTIME_CONFIG_COMPONENT, |cmd| { + async fn cli_serve_config() -> Result<()> { + let server = WasmtimeServe::new(CLI_SERVE_CONFIG_COMPONENT, |cmd| { cmd.arg("-Scli"); - cmd.arg("-Sruntime-config"); - cmd.arg("-Sruntime-config-var=hello=world"); + cmd.arg("-Sconfig"); + cmd.arg("-Sconfig-var=hello=world"); })?; let resp = server @@ -1945,12 +1945,12 @@ stderr [1] :: after empty } #[test] - fn cli_runtime_config() -> Result<()> { + fn cli_config() -> Result<()> { run_wasmtime(&[ "run", - "-Sruntime-config", - "-Sruntime-config-var=hello=world", - RUNTIME_CONFIG_GET_COMPONENT, + "-Sconfig", + "-Sconfig-var=hello=world", + CONFIG_GET_COMPONENT, ])?; Ok(()) }