Viceroy
Viceroy copied to clipboard
Support for arbitrary (or at least missing) ecp environment variables
#146 requested exposing the host machine's environment within the wasm runtime, and was rejected because that behaviour would not match the production network. Quoting @cratelyn there:
keeping the environment in which a Wasm program runs in parity with production is an important goal for Viceroy
We're missing a few environment variables that we have in prod on ecp proper: https://developer.fastly.com/reference/compute/ecp-env/
We could hardcode these to dummy values:
@@ -115,10 +115,19 @@ pub(crate) fn create_store(
fn make_wasi_ctx(ctx: &ExecuteCtx, session: &Session) -> Result<WasiCtx, anyhow::Error> {
let mut wasi_ctx = WasiCtxBuilder::new();
- // Viceroy provides a subset of the `FASTLY_*` environment variables that the production
+ // Viceroy provides the same `FASTLY_*` environment variables that the production
// Compute platform provides:
wasi_ctx
+ // These variables are stubbed out for compatibility
+ .env("FASTLY_CACHE_GENERATION", "0")?
+ .env("FASTLY_CUSTOMER_ID", "0000000000000000000000")?
+ .env("FASTLY_POP", "XXX")?
+ .env("FASTLY_REGION", "Somewhere")?
+ .env("FASTLY_SERVICE_ID", "0000000000000000000000")?
+ .env("FASTLY_SERVICE_VERSION", "0")?
+ .env("FASTLY_TRACE_ID", "00000000-0000-0000-0000-000000000000")?
+
But I think adding support for an array of environment variables in the config syntax might make sense, which gives the ability to set these explicitly. I think that's in the spirit of parity with prod, without exposing the entire host machine's environment. I don't know how to do this, or if it's actually a good idea.