From dc1bfbb5f574ede3fc73debf0df8acd6c4e399bd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 18 May 2023 17:29:37 +0200 Subject: [PATCH] feat: add GOPROXY + fix on saved inputs --- backend/sqlx-data.json | 21 +++++++++++++++++++ backend/src/main.rs | 1 + backend/windmill-api/src/folders.rs | 11 +++++++++- backend/windmill-api/src/inputs.rs | 2 +- backend/windmill-worker/src/go_executor.rs | 21 ++++++++++++------- backend/windmill-worker/src/worker.rs | 1 + .../src/lib/components/SavedInputs.svelte | 4 ++-- .../(logged)/flows/run/[...path]/+page.svelte | 20 ++++++++++-------- .../scripts/run/[...hash]/+page.svelte | 21 +++++++++++-------- 9 files changed, 73 insertions(+), 29 deletions(-) diff --git a/backend/sqlx-data.json b/backend/sqlx-data.json index 454aa15bb1..38fff41178 100644 --- a/backend/sqlx-data.json +++ b/backend/sqlx-data.json @@ -3002,6 +3002,27 @@ }, "query": "DELETE FROM usr WHERE email = $1 RETURNING username" }, + "7a819bbf0522315952fd94d9b320fdd58e5d71dbd7e5f79eaa83c14572159805": { + "describe": { + "columns": [ + { + "name": "count", + "ordinal": 0, + "type_info": "Int8" + } + ], + "nullable": [ + null + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + } + }, + "query": "SELECT count(path) FROM raw_app WHERE path LIKE 'f/' || $1 || '%' AND workspace_id = $2" + }, "7aef087f9e10dd32417477109b97c99b85d68ce1be2bafdc145aed0aa8e5d989": { "describe": { "columns": [], diff --git a/backend/src/main.rs b/backend/src/main.rs index fb03d17d0e..727416d694 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -143,6 +143,7 @@ Windmill Community Edition {GIT_VERSION} "DENO_PATH", "GO_PATH", "GOPRIVATE", + "GOPROXY", "NETRC", "PIP_INDEX_URL", "PIP_EXTRA_INDEX_URL", diff --git a/backend/windmill-api/src/folders.rs b/backend/windmill-api/src/folders.rs index bb6fcf86b8..7c86bdd310 100644 --- a/backend/windmill-api/src/folders.rs +++ b/backend/windmill-api/src/folders.rs @@ -405,6 +405,15 @@ async fn get_folder_usage( .await? .unwrap_or(0); + let raw_apps = sqlx::query_scalar!( + "SELECT count(path) FROM raw_app WHERE path LIKE 'f/' || $1 || '%' AND workspace_id = $2", + name, + w_id + ) + .fetch_one(&mut tx) + .await? + .unwrap_or(0); + let resources = sqlx::query_scalar!( "SELECT count(path) FROM resource WHERE path LIKE 'f/' || $1 || '%' AND workspace_id = $2", name, @@ -428,7 +437,7 @@ async fn get_folder_usage( scripts, flows, schedules, - apps, + apps: apps + raw_apps, resources, variables, })) diff --git a/backend/windmill-api/src/inputs.rs b/backend/windmill-api/src/inputs.rs index 75dfb1287e..e56c4220f3 100644 --- a/backend/windmill-api/src/inputs.rs +++ b/backend/windmill-api/src/inputs.rs @@ -169,7 +169,7 @@ async fn list_saved_inputs( let rows = sqlx::query_as::<_, InputRow>( "select * from input \ where runnable_id = $1 and runnable_type = $2 and workspace_id = $3 \ - and is_public IS true OR created_by = $4 \ + and (is_public IS true OR created_by = $4) \ order by created_at desc limit $5 offset $6", ) .bind(&r.runnable_id) diff --git a/backend/windmill-worker/src/go_executor.rs b/backend/windmill-worker/src/go_executor.rs index 3360b1006c..3efe04800e 100644 --- a/backend/windmill-worker/src/go_executor.rs +++ b/backend/windmill-worker/src/go_executor.rs @@ -17,8 +17,8 @@ use windmill_parser_go::parse_go_imports; use crate::{ common::{capitalize, read_result, set_logs}, create_args_and_out_file, get_reserved_variables, handle_child, write_file, - AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, GOPRIVATE, GO_CACHE_DIR, HOME_ENV, - NETRC, NSJAIL_PATH, PATH_ENV, + AuthedClientBackgroundTask, DISABLE_NSJAIL, DISABLE_NUSER, GOPRIVATE, GOPROXY, GO_CACHE_DIR, + HOME_ENV, NETRC, NSJAIL_PATH, PATH_ENV, }; const GO_REQ_SPLITTER: &str = "//go.sum\n"; @@ -207,16 +207,23 @@ func Run(req Req) (interface{{}}, error){{ if let Some(ref netrc) = *NETRC { write_file(&HOME_ENV, ".netrc", netrc).await?; } - Command::new(GO_PATH.as_str()) - .current_dir(job_dir) + let mut cmd = Command::new(GO_PATH.as_str()); + cmd.current_dir(job_dir) .env_clear() .envs(reserved_variables) .env("PATH", PATH_ENV.as_str()) .env("BASE_INTERNAL_URL", base_internal_url) .env("GOPATH", GO_CACHE_DIR) - .env("GOPRIVATE", GOPRIVATE.as_ref().unwrap_or(&String::new())) - .env("HOME", HOME_ENV.as_str()) - .args(vec!["run", "main.go"]) + .env("HOME", HOME_ENV.as_str()); + + if let Some(ref goprivate) = *GOPRIVATE { + cmd.env("GOPRIVATE", goprivate); + } + if let Some(ref goproxy) = *GOPROXY { + cmd.env("GOPROXY", goproxy); + } + + cmd.args(vec!["run", "main.go"]) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn()? diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 53a33b7012..c2698dc90e 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -178,6 +178,7 @@ lazy_static::lazy_static! { pub static ref PATH_ENV: String = std::env::var("PATH").unwrap_or_else(|_| String::new()); pub static ref HOME_ENV: String = std::env::var("HOME").unwrap_or_else(|_| String::new()); pub static ref GOPRIVATE: Option = std::env::var("GOPRIVATE").ok(); + pub static ref GOPROXY: Option = std::env::var("GOPROXY").ok(); pub static ref NETRC: Option = std::env::var("NETRC").ok(); static ref DENO_AUTH_TOKENS: String = std::env::var("DENO_AUTH_TOKENS") diff --git a/frontend/src/lib/components/SavedInputs.svelte b/frontend/src/lib/components/SavedInputs.svelte index 70437edb4f..564fe1e99e 100644 --- a/frontend/src/lib/components/SavedInputs.svelte +++ b/frontend/src/lib/components/SavedInputs.svelte @@ -15,7 +15,7 @@ export let scriptPath: string | null = null export let flowPath: string | null = null - let runnableId: string | undefined = scriptHash || scriptPath || flowPath || undefined + let runnableId: string | undefined = scriptPath || flowPath || undefined let runnableType: RunnableType | undefined = scriptHash ? RunnableType.SCRIPT_HASH : scriptPath @@ -146,7 +146,7 @@
Saved Inputs Shared tooltips are available to anyone with access to the scriptShared inputs are available to anyone with access to the script