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

environment vars for single module removed? #117

Open
linux-china opened this issue Aug 26, 2021 · 1 comment
Open

environment vars for single module removed? #117

linux-china opened this issue Aug 26, 2021 · 1 comment

Comments

@linux-china
Copy link

wagi --env is good for global env vars for all modules, but for some cases, I need to inject some secret vars for a Wasm module only, not for all modules. I found the example from https://github.com/deislabs/wagi-examples/tree/main/env_wagi

[[module]]
# Mount this to example.com/env
route = "/env"
# Point to the directory that 'cargo build' wrote the WASM file
module = "/path/to/env_wagi/target/wasm32-wasi/release/env_wagi.wasm"
# Mount the source code of this repo
volumes = { "/" = "/path/to/env_wagi" }
# Set an environment variable
environment.TEST_NAME = "test value"

But it does not work on 0.3.0, any clue?

pub struct Module {
    /// The route, begining with a leading slash.
    ///
    /// The suffix "/..." means "this route and all sub-paths". For example, the route
    /// "/foo/..." will match "/foo" as well as "/foo/bar" and "/foo/bar/baz"
    pub route: String,
    /// The path to the module that will be loaded.
    ///
    /// This should be an absolute path. It must point to a WASM+WASI 32-bit program
    /// with the read bit set.
    pub module: String,
    /// Directories on the local filesystem that can be opened by this module
    /// The key (left value) is the name of the directory INSIDE the WASM. The value is
    /// the location OUTSIDE the WASM. Two inside locations can map to the same outside
    /// location.
    pub volumes: Option<HashMap<String, String>>,
    /// The name of the function that is the entrypoint for executing the module.
    /// The default is `_start`.
    pub entrypoint: Option<String>,
    /// The URL fragment for the bindle server.
    ///
    /// If none is supplied, then http://localhost:8080/v1 is used
    pub bindle_server: Option<String>,

    /// List of hosts that the guest module is allowed to make HTTP requests to.
    /// If none or an empty vector is supplied, the guest module cannot send
    /// requests to any server.
    pub allowed_hosts: Option<Vec<String>>,

    /// Max http concurrency that the guest module configures for the HTTP
    /// client. If none, the guest module uses the default concurrency provided
    /// by the WASM HTTP client module.
    pub http_max_concurrency: Option<u32>,
}
@technosophos
Copy link
Contributor

We did intentionally remove support for per-module env vars pending a redesign of how we handle environment variables with the new Bindle support.

The intent is to make bindles the default method of loading modules into Wagi (though we are still planning on supporting modules.toml). But since the bindle is created by the dev team (rather than the ops team), we do not think that we should but the environment variables inside of the bindle.

I think what we need to figure out is how we can pass env vars from the CLI to specific modules. We are still pretty open to coming up with other solutions, though.

In the meantime, I will look to see whether we can simply re-enable the old env var code until we come up with a better way.

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

No branches or pull requests

2 participants