feat: add whitelist envs to passthrough the workers

This commit is contained in:
Ruben Fiszel
2023-07-15 19:51:15 +02:00
parent 62c33eec83
commit 98fa6db9c1
2 changed files with 20 additions and 6 deletions
+2 -1
View File
@@ -203,7 +203,7 @@ compiling from source or using without a postgres super user, see
curl https://raw.githubusercontent.com/windmill-labs/windmill/main/docker-compose.yml -o docker-compose.yml
curl https://raw.githubusercontent.com/windmill-labs/windmill/main/Caddyfile -o Caddyfile
curl https://raw.githubusercontent.com/windmill-labs/windmill/main/.env -o .env
curl https://raw.githubusercontent.com/windmill-labs/windmill/main/oauth.json -o oauth.json
curl https://raw.githubusercontent.com/windmill-labs/windmill/main/oauth.json -o oauth.json
docker compose up -d
```
@@ -389,6 +389,7 @@ it being synced automatically everyday.
| SMTP_TLS_IMPLICIT | false | https://docs.rs/mail-send/latest/mail_send/struct.SmtpClientBuilder.html#method.implicit_tlsemails | Server |
| CREATE_WORKSPACE_REQUIRE_SUPERADMIN | false | If true, only superadmin can create workspaces | Server |
| GLOBAL_ERROR_HANDLER_PATH_IN_ADMINS_WORKSPACE | None | Path to a script to run when a root job fails. The script will be run in and from the admins workspace | Server |
| WHITELIST_ENVS | None | List of envs variables, separated by a ',' that are whitelisted as being safe to passthrough the workers | Worker |
## Run a local dev setup
+18 -5
View File
@@ -208,6 +208,10 @@ lazy_static::lazy_static! {
pub static ref WHITELIST_ENVS: Option<Vec<(String, String)>> = std::env::var("WHITELIST_ENVS")
.ok()
.map(|x| x.split(',').map(|x| (x.to_string(), std::env::var(x).unwrap_or("".to_string()))).collect());
static ref WHITELIST_WORKSPACES: Option<Vec<String>> = std::env::var("WHITELIST_WORKSPACES")
.ok()
.map(|x| x.split(',').map(|x| x.to_string()).collect());
@@ -2333,11 +2337,20 @@ pub async fn get_reserved_variables(
job.parent_job.map(|x| x.to_string()),
flow_path,
job.schedule_path.clone()
);
Ok(variables
.into_iter()
.map(|rv| (rv.name, rv.value))
.collect())
).to_vec();
let mut r: HashMap<String, String> = variables
.into_iter()
.map(|rv| (rv.name, rv.value))
.collect();
if let Some(ref envs) = *WHITELIST_ENVS {
for e in envs {
r.insert(e.0.clone(), e.1.clone());
}
}
Ok(r)
}
async fn get_mem_peak(pid: Option<u32>, nsjail: bool) -> i32 {