mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-07 08:02:20 +00:00
fix: lock file in metadata is now a string (#3027)
This commit is contained in:
@@ -3148,7 +3148,7 @@ async fn run_deployed_relative_imports(db: &Pool<Postgres>, script_content: Stri
|
||||
is_template: None,
|
||||
kind: None,
|
||||
parent_hash: None,
|
||||
lock: vec![],
|
||||
lock: None,
|
||||
summary: "".to_string(),
|
||||
tag: None,
|
||||
schema: std::collections::HashMap::new(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
version: 1.244.2
|
||||
version: 1.246.4
|
||||
title: Windmill API
|
||||
contact:
|
||||
name: Windmill Team
|
||||
@@ -2086,6 +2086,29 @@ paths:
|
||||
- token_prefix
|
||||
- created_at
|
||||
- last_used_at
|
||||
/w/{workspace}/oidc/token/{audience}:
|
||||
post:
|
||||
summary: get OIDC token (ee only)
|
||||
operationId: getOidcToken
|
||||
tags:
|
||||
- oidc
|
||||
parameters:
|
||||
- name: workspace
|
||||
in: path
|
||||
required: true
|
||||
schema: *ref_0
|
||||
- name: audience
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: new oidc token
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
/w/{workspace}/variables/create:
|
||||
post:
|
||||
summary: create variable
|
||||
@@ -4312,9 +4335,7 @@ paths:
|
||||
is_template:
|
||||
type: boolean
|
||||
lock:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
language:
|
||||
type: string
|
||||
enum:
|
||||
@@ -6767,7 +6788,7 @@ paths:
|
||||
items:
|
||||
type: object
|
||||
properties: &ref_184
|
||||
content:
|
||||
raw_code:
|
||||
type: string
|
||||
path:
|
||||
type: string
|
||||
@@ -6788,7 +6809,7 @@ paths:
|
||||
- nativets
|
||||
- bun
|
||||
required: &ref_185
|
||||
- content
|
||||
- raw_code
|
||||
- path
|
||||
- language
|
||||
entrypoint:
|
||||
|
||||
@@ -7625,9 +7625,7 @@ components:
|
||||
is_template:
|
||||
type: boolean
|
||||
lock:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
language:
|
||||
type: string
|
||||
enum:
|
||||
@@ -9379,7 +9377,7 @@ components:
|
||||
RawScriptForDependencies:
|
||||
type: object
|
||||
properties:
|
||||
content:
|
||||
raw_code:
|
||||
type: string
|
||||
path:
|
||||
type: string
|
||||
@@ -9402,6 +9400,6 @@ components:
|
||||
bun,
|
||||
]
|
||||
required:
|
||||
- content
|
||||
- raw_code
|
||||
- path
|
||||
- language
|
||||
|
||||
@@ -456,8 +456,6 @@ async fn create_script(
|
||||
Some(String::new())
|
||||
} else {
|
||||
ns.lock
|
||||
.as_ref()
|
||||
.map(|x| x.join("\n"))
|
||||
.and_then(|e| if e.is_empty() { None } else { Some(e) })
|
||||
};
|
||||
|
||||
|
||||
@@ -1813,7 +1813,7 @@ struct ScriptMetadata {
|
||||
description: String,
|
||||
schema: Option<Schema>,
|
||||
is_template: bool,
|
||||
lock: Vec<String>,
|
||||
lock: Option<String>,
|
||||
kind: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
envs: Option<Vec<String>>,
|
||||
@@ -2021,19 +2021,13 @@ async fn tarball_workspace(
|
||||
.write_to_archive(&script.content, &format!("{}.{}", script.path, ext))
|
||||
.await?;
|
||||
|
||||
let lock = script
|
||||
.lock
|
||||
.unwrap_or_else(|| "".to_string())
|
||||
.lines()
|
||||
.map(|x| x.to_string())
|
||||
.collect();
|
||||
let metadata = ScriptMetadata {
|
||||
summary: script.summary,
|
||||
description: script.description,
|
||||
schema: script.schema,
|
||||
is_template: script.is_template,
|
||||
kind: script.kind.to_string(),
|
||||
lock,
|
||||
lock: script.lock,
|
||||
envs: script.envs,
|
||||
concurrent_limit: script.concurrent_limit,
|
||||
concurrency_time_window_s: script.concurrency_time_window_s,
|
||||
|
||||
@@ -240,7 +240,9 @@ pub struct NewScript {
|
||||
pub content: String,
|
||||
pub schema: Option<Schema>,
|
||||
pub is_template: Option<bool>,
|
||||
pub lock: Option<Vec<String>>,
|
||||
#[serde(default = "Option::default")]
|
||||
#[serde(deserialize_with = "lock_deserialize")]
|
||||
pub lock: Option<String>,
|
||||
pub language: ScriptLang,
|
||||
pub kind: Option<ScriptKind>,
|
||||
pub tag: Option<String>,
|
||||
@@ -258,6 +260,52 @@ pub struct NewScript {
|
||||
pub deployment_message: Option<String>,
|
||||
}
|
||||
|
||||
fn lock_deserialize<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
|
||||
where
|
||||
D: serde::de::Deserializer<'de>,
|
||||
{
|
||||
struct StringOrArrayVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for StringOrArrayVisitor {
|
||||
type Value = Option<String>;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("either a string or an array of strings")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
Ok(Some(v.to_string()))
|
||||
}
|
||||
|
||||
fn visit_none<E>(self) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
A: serde::de::SeqAccess<'de>,
|
||||
{
|
||||
let mut split_lock: Vec<String> = vec![];
|
||||
loop {
|
||||
if let Ok(Some(elem)) = seq.next_element::<String>() {
|
||||
split_lock.push(elem);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let lock = split_lock.join("\n");
|
||||
return Ok(Some(lock));
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_any(StringOrArrayVisitor)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct ListScriptQuery {
|
||||
pub path_start: Option<String>,
|
||||
|
||||
+3
-2
@@ -69,6 +69,7 @@ export async function handleScriptMetadata(
|
||||
}
|
||||
|
||||
async function parseMetadataFile(scriptPath: string): Promise<{isJson: boolean, payload: any} | undefined> {
|
||||
|
||||
let metadataFilePath = scriptPath + ".script.json";
|
||||
try {
|
||||
await Deno.stat(metadataFilePath);
|
||||
@@ -126,7 +127,7 @@ export async function handleFile(
|
||||
const remotePath = path
|
||||
.substring(0, path.indexOf("."))
|
||||
.replaceAll("\\", "/");
|
||||
const typed = (await parseMetadataFile(path))?.payload;
|
||||
const typed = (await parseMetadataFile(remotePath))?.payload;
|
||||
const language = inferContentTypeFromFilePath(path);
|
||||
|
||||
let remote = undefined;
|
||||
@@ -831,7 +832,7 @@ async function updateScriptLock(workspace: Workspace, scriptContent: string, lan
|
||||
if (lock === undefined) {
|
||||
throw new Error(`Failed to generate lockfile. Full response was: ${JSON.stringify(response)}`);
|
||||
}
|
||||
metadataContent.lock = lock.split("\n");
|
||||
metadataContent.lock = lock;
|
||||
} catch {
|
||||
throw new Error(`Failed to generate lockfile. Status was: ${rawResponse.statusText}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user