Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flesh out variables implementation #114

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Flesh out variables implementation #114

merged 2 commits into from
Jul 31, 2024

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Jul 30, 2024

Uses spin-expressions to more fully implement the variables interface.

This also provides a new interface in tests for setting application variables. For example:

With this in the spin.toml

[variables]
secret = { required = true }
# ...
[component.my-component.variables]
my_secret = "{{secret}}"

And the following in the test:

spin_test_sdk::bindings::fermyon::spin_test_virt::variables::set("secret", "PASSWORD");

The following in the Spin app:

let value = variables::get("my_secret").unwrap_or("unknown".to_string());
println!("VALUE: {:?}", value);

The following would be printed:

VALUE: "PASSWORD"

@rylev rylev requested a review from fibonacci1729 July 30, 2024 14:02
Copy link
Contributor

@fibonacci1729 fibonacci1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@rylev rylev merged commit 30774ce into main Jul 31, 2024
9 checks passed
@rylev rylev deleted the variables branch July 31, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants