-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: itowlson <[email protected]>
- Loading branch information
Showing
15 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ wasmtime::component::bindgen!({ | |
"fermyon:spin/[email protected]/error" => v2::sqlite::Error, | ||
"fermyon:spin/sqlite/error" => v1::sqlite::Error, | ||
"fermyon:spin/[email protected]/error" => v2::variables::Error, | ||
"wasi:config/store/error" => wasi::config::store::Error, | ||
}, | ||
trappable_imports: true, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
spin_manifest_version = "1" | ||
authors = [""] | ||
description = "" | ||
name = "variables" | ||
trigger = { type = "http" } | ||
version = "0.1.0" | ||
|
||
[variables] | ||
variable = { default = "value" } | ||
|
||
[[component]] | ||
id = "variables" | ||
source = "%{source=variables}" | ||
[component.trigger] | ||
route = "/..." | ||
[component.config] | ||
variable = "{{ variable }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
spin_manifest_version = "1" | ||
authors = [""] | ||
description = "" | ||
name = "wasi-config" | ||
trigger = { type = "http" } | ||
version = "0.1.0" | ||
|
||
[variables] | ||
variable = { default = "value" } | ||
|
||
[[component]] | ||
id = "wasi-config" | ||
source = "%{source=wasi-config}" | ||
[component.trigger] | ||
route = "/..." | ||
[component.config] | ||
variable = "{{ variable }}" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "wasi-config" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
helper = { path = "../../helper" } | ||
wit-bindgen = "0.16.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Variables | ||
|
||
Tests the wasi:config interface. | ||
|
||
## Expectations | ||
|
||
This test component expects the following to be true: | ||
* Only the variable named "variable" is defined with value "value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use helper::ensure_matches; | ||
|
||
use bindings::wasi::config::store::{get, get_all}; | ||
|
||
helper::define_component!(Component); | ||
|
||
impl Component { | ||
fn main() -> Result<(), String> { | ||
ensure_matches!(get("variable"), Ok(Some(val)) if val == "value"); | ||
ensure_matches!(get("non_existent"), Ok(None)); | ||
|
||
let expected_all = vec![ | ||
("variable".to_owned(), "value".to_owned()), | ||
]; | ||
ensure_matches!(get_all(), Ok(val) if val == expected_all); | ||
|
||
ensure_matches!(get("invalid-name"), Ok(None)); | ||
ensure_matches!(get("invalid!name"), Ok(None)); | ||
ensure_matches!(get("4invalidname"), Ok(None)); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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. | ||
upstream(string), | ||
/// This indicates an error from an I/O operation. | ||
/// As this could be almost _anything_ (such as a file read, network connection, etc), | ||
/// the error message is a string. | ||
/// Depending on how this ends up being consumed, | ||
/// we may consider moving this to use the `wasi:io/error` type instead. | ||
/// For simplicity right now in supporting multiple implementations, it is being left as a string. | ||
io(string), | ||
} | ||
|
||
/// Gets a configuration value of type `string` associated with the `key`. | ||
/// | ||
/// The value is returned as an `option<string>`. 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<option<string>, 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<list<tuple<string, string>>, error>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package wasi:config@0.2.0-draft; | ||
|
||
world imports { | ||
/// The interface for wasi:config/store | ||
import store; | ||
} |