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

feat: configure and inject environment variables in workers #42

Merged
merged 3 commits into from
Nov 23, 2022

Conversation

Angelmmiguel
Copy link
Contributor

Configure environment variables via configuration files (TOML files with the same name of the worker). These variables will be configured in the vars section. Teh value can be static (string) or inherited from the current context ($VAR). In the second case, wws will initialized it to an empty string if the given environment variable doesn't exist in the current context.

This is an example of configuration file:

name = "test"
version = "1"

[vars]
MESSAGE = "Hello 👋! This message comes from an environment variable"

The usage of environment variables depends on the selected language:

  • Rust: retrieve them using std::env
  • JavaScript: environment variables are injected as global constants

You have all the information and examples in the documentation I added to this PR.

It closes #34

@Angelmmiguel Angelmmiguel added the 🚀 enhancement New feature or request label Nov 23, 2022
@Angelmmiguel Angelmmiguel self-assigned this Nov 23, 2022
Copy link
Contributor

@assambar assambar left a comment

Choose a reason for hiding this comment

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

Greate feature! Just one small note on the docs.

docs/docs/tutorials/rust-workers.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Really great contribution. LGTM, a minor comment to get rid of mutability on the WASI context builder.

src/runner.rs Outdated Show resolved Hide resolved
@Angelmmiguel Angelmmiguel merged commit b356e20 into main Nov 23, 2022
@Angelmmiguel Angelmmiguel deleted the 34-add-environment-variables branch May 8, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for environment variables
4 participants