mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-01 00:08:24 +00:00
fix: copy labels into forks and detect label changes in compare (#12738)
* fix: copy labels into forks and detect label changes in compare Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show labels in the compare diff and bump windmill-utils-internal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: normalize app labels in the compare diff Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep target labels when a fork item has none set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: publish utils-internal under the @windmill-labs org Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: publish utils-internal on release with trusted publishing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: build the frontend from utils-internal source Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: drop the utils-internal version bump Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump utils-internal to 1.8.7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
co-authored by
Claude Opus 5.5
Ruben Fiszel
parent
876fbb1e09
commit
f79e4b618d
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO app (workspace_id, path, summary, policy, versions, extra_perms, custom_path)\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING id",
|
||||
"query": "INSERT INTO app (workspace_id, path, summary, policy, versions, extra_perms, custom_path, labels)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n RETURNING id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -17,12 +17,13 @@
|
||||
"Jsonb",
|
||||
"Int8Array",
|
||||
"Jsonb",
|
||||
"Text"
|
||||
"Text",
|
||||
"TextArray"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "c61977907414d2336030fbab114ea03e4a1d1edb4470812cd7dd57c657fa287a"
|
||||
"hash": "138fda3e2e7f83f5f60b7990efed2cedbaec80b4a54e4396b40ee5f3d15abcd2"
|
||||
}
|
||||
+9
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT value, description, resource_type\n FROM resource\n WHERE workspace_id = $1 AND path = $2",
|
||||
"query": "SELECT value, description, resource_type, labels\n FROM resource\n WHERE workspace_id = $1 AND path = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -17,6 +17,11 @@
|
||||
"ordinal": 2,
|
||||
"name": "resource_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -28,8 +33,9 @@
|
||||
"nullable": [
|
||||
true,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "819c233915383e89af1bcf1a56c5f67c4e1fc217f216f609e36a9944a7807b33"
|
||||
"hash": "1473ebd933fbda4550c63c81bddc3486fac4f9c2d0643e8eb15b169c1a900a3a"
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT hash, created_at, content, summary, description, lock, schema\n FROM script\n WHERE workspace_id = $1 AND path = $2 AND archived = false\n ORDER BY created_at DESC\n LIMIT 1",
|
||||
"query": "SELECT hash, created_at, content, summary, description, lock, schema, labels\n FROM script\n WHERE workspace_id = $1 AND path = $2 AND archived = false\n ORDER BY created_at DESC\n LIMIT 1",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -37,6 +37,11 @@
|
||||
"ordinal": 6,
|
||||
"name": "schema",
|
||||
"type_info": "Json"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -52,8 +57,9 @@
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "a6fe41e36e06c88e1387abaea17107ceab2c5b17258958bde03b3e492bb2790e"
|
||||
"hash": "398b309a86c3abe0b8daf2ec256dd4eac403ea69d09d7b13d6f5a0b21e2b034a"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow (\n workspace_id, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, dependency_job, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,\n job_token_scopes, labels\n )\n SELECT $2, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, NULL, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, ARRAY[]::bigint[],\n -- Same predicate as clone_scripts.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $2::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, lock_error_logs, job_token_scopes, labels\n FROM flow\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "4a5679413cd1f5b1b2822a4804a54b2a5a008d7c3313c90fb80d431057223b34"
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, workspace_id, path, summary, policy, versions, extra_perms, custom_path\n FROM app\n WHERE workspace_id = $1",
|
||||
"query": "SELECT id, workspace_id, path, summary, policy, versions, extra_perms, custom_path, labels\n FROM app\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -42,6 +42,11 @@
|
||||
"ordinal": 7,
|
||||
"name": "custom_path",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -57,8 +62,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "26fb727ef7d50c93c1c8ce33356ef6feafc448e70c30ba7e7c835f5e3167f3a5"
|
||||
"hash": "4fff0ec1067f69aa3b67f73e3a7c84177a1050456baa43d348e8b467c5db3b75"
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT display_name, owners, extra_perms, summary\n FROM folder\n WHERE workspace_id = $1 AND name = $2",
|
||||
"query": "SELECT display_name, owners, extra_perms, summary, labels\n FROM folder\n WHERE workspace_id = $1 AND name = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -22,6 +22,11 @@
|
||||
"ordinal": 3,
|
||||
"name": "summary",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -34,8 +39,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "8039b459914ceefe0c0a31b97473a5522e47b4b2fd3ddeff8f221560bc9c6f57"
|
||||
"hash": "5bd796933edd56a80add193599714e763d17f9514b0746e9e389699c95f6bb7d"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by, labels)\n SELECT $2, path,\n CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'\n AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'\n THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))\n ELSE value END,\n description, resource_type, extra_perms, edited_at, created_by, labels\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "6c1798b9a60634e908852e65e7583a9bc7d8e6f97559b1f6a2a069a073b7e48c"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO script (\n workspace_id, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes\n )\n SELECT\n $1, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n -- Same three forms and the same prefix-first rule as permissioned_as_exists,\n -- superadmin fallback included: one acting outside their workspaces has no usr\n -- row but still authenticates.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $1::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, assets, modules, job_token_scopes\n FROM script\n WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "706f2227e34971d22a577b33f6aaa7f5755da9997419c4a9d07b30d4da318bea"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO script (\n workspace_id, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes, labels\n )\n SELECT\n $1, hash, path, parent_hashes, summary, description, content,\n created_by, created_at, archived, schema, deleted, is_template,\n extra_perms, lock, lock_error_logs, language, kind, tag,\n envs, concurrent_limit, concurrency_time_window_s, cache_ttl,\n dedicated_worker, ws_error_handler_muted, priority, timeout,\n delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,\n visible_to_runner_only, auto_kind, codebase, has_preprocessor,\n -- Same three forms and the same prefix-first rule as permissioned_as_exists,\n -- superadmin fallback included: one acting outside their workspaces has no usr\n -- row but still authenticates.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $1::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $1::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, assets, modules, job_token_scopes, labels\n FROM script\n WHERE workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "78d53c53d22bdd8948a3375a19a2b3a87eb50150eb7b6888bc32a9d48a5ad21f"
|
||||
}
|
||||
+9
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT app.summary, app.policy, app_version.value, app_version.raw_app\n FROM app\n JOIN app_version\n ON app_version.id = app.versions[array_upper(app.versions, 1)]\n WHERE app.workspace_id = $1 AND app.path = $2",
|
||||
"query": "SELECT app.summary, app.policy, app_version.value, app_version.raw_app, app.labels\n FROM app\n JOIN app_version\n ON app_version.id = app.versions[array_upper(app.versions, 1)]\n WHERE app.workspace_id = $1 AND app.path = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -22,6 +22,11 @@
|
||||
"ordinal": 3,
|
||||
"name": "raw_app",
|
||||
"type_info": "Bool"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -34,8 +39,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "ac09d8de92d8e1ee9b463b87b2374e11ba46e9b392414282d2d67161a6544d11"
|
||||
"hash": "a8f41490f55dea4b7f5497111d925ac5be5518831a9896c3949d32fe3eda0f3e"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO variable (workspace_id, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until)\n SELECT $2, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until\n FROM variable\n WHERE workspace_id = $1",
|
||||
"query": "INSERT INTO variable (workspace_id, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until, labels)\n SELECT $2, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until, labels\n FROM variable\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -11,5 +11,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "809a2dd647ddfc6fa79ca2c9039e4ebfc4b2880600a03b82e60b89c4a1fd5cc8"
|
||||
"hash": "ab305b4e020220ba25c5c8263cb569991adb42acea00b109c74eb16bd8361dd6"
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT value::text AS \"value!\", is_secret, description, value_valid_until\n FROM variable\n WHERE workspace_id = $1 AND path = $2",
|
||||
"query": "SELECT value::text AS \"value!\", is_secret, description, value_valid_until, labels\n FROM variable\n WHERE workspace_id = $1 AND path = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -22,6 +22,11 @@
|
||||
"ordinal": 3,
|
||||
"name": "value_valid_until",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -34,8 +39,9 @@
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "30f69fd4baef17716d26cc59bf6369d6768972478def50010f680103d7c4281b"
|
||||
"hash": "b7ecb69c99a1c840c400340c51e0a1b30410e587cf35d9488c5e5f4fc8c3ab58"
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)\n SELECT $2, path,\n CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'\n AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'\n THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))\n ELSE value END,\n description, resource_type, extra_perms, edited_at, created_by\n FROM resource\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "bf763c3ae4951537033d18ce48d3eb83d5c19e32aef199bf161e8ba8d1adf176"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO raw_app (path, version, workspace_id, summary, edited_at, data, extra_perms)\n SELECT path, version, $2, summary, edited_at, data, extra_perms\n FROM raw_app\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "cde6d13d0a072e7910591335580434f0418b2ee23dc70e734568f820eec4b813"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO flow (\n workspace_id, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, dependency_job, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,\n job_token_scopes\n )\n SELECT $2, path, summary, description, value, edited_by, edited_at,\n archived, schema, extra_perms, NULL, tag,\n ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,\n concurrency_key, ARRAY[]::bigint[],\n -- Same predicate as clone_scripts.\n CASE WHEN on_behalf_of LIKE 'u/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = substring(on_behalf_of from 3)\n UNION ALL\n SELECT 1 FROM password p WHERE p.super_admin\n AND (p.username = substring(on_behalf_of from 3)\n OR p.email = substring(on_behalf_of from 3))))\n WHEN on_behalf_of LIKE 'g/%' THEN\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM group_ g WHERE g.workspace_id = $2::varchar\n AND g.name = substring(on_behalf_of from 3)))\n ELSE\n (SELECT on_behalf_of WHERE EXISTS (\n SELECT 1 FROM usr u WHERE u.workspace_id = $2::varchar\n AND u.username = on_behalf_of\n UNION ALL\n SELECT 1 FROM password p WHERE p.email = on_behalf_of\n AND p.super_admin))\n END, on_behalf_of_email, lock_error_logs, job_token_scopes\n FROM flow\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "df1fe2e7ef004b8de0e626f40fd737b3b4b662a89148cf6ac70eb3563ad7f0c5"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO raw_app (path, version, workspace_id, summary, edited_at, data, extra_perms, labels)\n SELECT path, version, $2, summary, edited_at, data, extra_perms, labels\n FROM raw_app\n WHERE workspace_id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "f2d208bcb735dcc3c24c8e09b5720037162032a79fc54a03652322a1543161a5"
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT value, summary, description, schema\n FROM flow\n WHERE workspace_id = $1 AND path = $2 AND archived = false",
|
||||
"query": "SELECT value, summary, description, schema, labels\n FROM flow\n WHERE workspace_id = $1 AND path = $2 AND archived = false",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -22,6 +22,11 @@
|
||||
"ordinal": 3,
|
||||
"name": "schema",
|
||||
"type_info": "Json"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "labels",
|
||||
"type_info": "TextArray"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -34,8 +39,9 @@
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "dc6ffc9946325e794f3a9d1cf621a9c07d211351195c399f6ff25c1dc7adb01a"
|
||||
"hash": "f4389161e4c6d6379c57fd1cd8c6fa9360f4c7ee5608be2fd7b26f0e04878278"
|
||||
}
|
||||
@@ -467,3 +467,47 @@ async fn test_fork_repoints_unresolvable_identities(db: Pool<Postgres>) -> anyho
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Labels are compared on the compare page, so a fork that drops them shows every labelled item
|
||||
/// as changed.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_fork_copies_labels(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let base_url = format!("http://localhost:{}/api", server.addr.port());
|
||||
|
||||
for q in [
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, labels, created_by)
|
||||
VALUES ('test-workspace', 'u/test-user/lr', '{}', 'generic', '{a,b}', 'test-user')",
|
||||
"INSERT INTO variable (workspace_id, path, value, is_secret, description, labels)
|
||||
VALUES ('test-workspace', 'u/test-user/lv', 'x', false, '', '{a,b}')",
|
||||
] {
|
||||
sqlx::query(q).execute(&db).await?;
|
||||
}
|
||||
|
||||
let resp = reqwest::Client::new()
|
||||
.post(format!(
|
||||
"{base_url}/w/test-workspace/workspaces/create_fork"
|
||||
))
|
||||
.header("Authorization", "Bearer SECRET_TOKEN")
|
||||
.json(&json!({ "id": "wm-fork-labels", "name": "Fork" }))
|
||||
.send()
|
||||
.await?;
|
||||
assert!(
|
||||
resp.status().is_success(),
|
||||
"creating the fork: {}",
|
||||
resp.text().await?
|
||||
);
|
||||
|
||||
let labels: Vec<Option<Vec<String>>> = sqlx::query_scalar(
|
||||
"SELECT labels FROM resource WHERE workspace_id = 'wm-fork-labels' AND path = 'u/test-user/lr'
|
||||
UNION ALL
|
||||
SELECT labels FROM variable WHERE workspace_id = 'wm-fork-labels' AND path = 'u/test-user/lv'",
|
||||
)
|
||||
.fetch_all(&db)
|
||||
.await?;
|
||||
let ab = Some(vec!["a".to_string(), "b".to_string()]);
|
||||
assert_eq!(labels, [ab.clone(), ab]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2592,9 +2592,12 @@ async fn test_rename_records_the_vacated_path(db: Pool<Postgres>) -> anyhow::Res
|
||||
}
|
||||
|
||||
/// Regression: a resource or resource type can be stored with a NULL description while deploy
|
||||
/// writes "", so the comparison must read the two as equal or the item never settles.
|
||||
/// writes "", and labels as NULL or `{}`, so the comparison must read each pair as equal or the
|
||||
/// item never settles. A difference in labels alone is still a change.
|
||||
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
|
||||
async fn test_compare_null_description_equals_empty(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
async fn test_compare_null_description_and_labels_equal_empty(
|
||||
db: Pool<Postgres>,
|
||||
) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
@@ -2616,6 +2619,11 @@ async fn test_compare_null_description_equals_empty(db: Pool<Postgres>) -> anyho
|
||||
('wm-fork-test-workspace', 'u/test-user/null_desc', '{}', 'generic', '', 'test-user'),
|
||||
('test-workspace', 'u/test-user/other_desc', '{}', 'generic', NULL, 'test-user'),
|
||||
('wm-fork-test-workspace', 'u/test-user/other_desc', '{}', 'generic', 'x', 'test-user')",
|
||||
"INSERT INTO resource (workspace_id, path, value, resource_type, labels, created_by) VALUES
|
||||
('test-workspace', 'u/test-user/null_labels', '{}', 'generic', NULL, 'test-user'),
|
||||
('wm-fork-test-workspace', 'u/test-user/null_labels', '{}', 'generic', '{}', 'test-user'),
|
||||
('test-workspace', 'u/test-user/other_labels', '{}', 'generic', NULL, 'test-user'),
|
||||
('wm-fork-test-workspace', 'u/test-user/other_labels', '{}', 'generic', '{x}', 'test-user')",
|
||||
"INSERT INTO resource_type (workspace_id, name, schema, description, created_by) VALUES
|
||||
('test-workspace', 'null_desc_rt', '{}', NULL, 'test-user'),
|
||||
('wm-fork-test-workspace', 'null_desc_rt', '{}', '', 'test-user'),
|
||||
@@ -2626,7 +2634,9 @@ async fn test_compare_null_description_equals_empty(db: Pool<Postgres>) -> anyho
|
||||
('test-workspace', 'wm-fork-test-workspace', 'u/test-user/null_desc', 'resource', 1, 1, NULL),
|
||||
('test-workspace', 'wm-fork-test-workspace', 'u/test-user/other_desc', 'resource', 1, 1, NULL),
|
||||
('test-workspace', 'wm-fork-test-workspace', 'null_desc_rt', 'resource_type', 1, 1, NULL),
|
||||
('test-workspace', 'wm-fork-test-workspace', 'other_desc_rt', 'resource_type', 1, 1, NULL)",
|
||||
('test-workspace', 'wm-fork-test-workspace', 'other_desc_rt', 'resource_type', 1, 1, NULL),
|
||||
('test-workspace', 'wm-fork-test-workspace', 'u/test-user/null_labels', 'resource', 1, 1, NULL),
|
||||
('test-workspace', 'wm-fork-test-workspace', 'u/test-user/other_labels', 'resource', 1, 1, NULL)",
|
||||
] {
|
||||
sqlx::query(q).execute(&db).await?;
|
||||
}
|
||||
@@ -2649,7 +2659,11 @@ async fn test_compare_null_description_equals_empty(db: Pool<Postgres>) -> anyho
|
||||
paths.sort();
|
||||
assert_eq!(
|
||||
paths,
|
||||
["other_desc_rt", "u/test-user/other_desc"],
|
||||
[
|
||||
"other_desc_rt",
|
||||
"u/test-user/other_desc",
|
||||
"u/test-user/other_labels"
|
||||
],
|
||||
"{comparison}"
|
||||
);
|
||||
|
||||
|
||||
@@ -8416,13 +8416,13 @@ async fn clone_resources(
|
||||
let repoint = (!windmill_common::can_preserve_on_behalf_of(authed))
|
||||
.then(|| username_to_permissioned_as(&authed.username));
|
||||
sqlx::query!(
|
||||
"INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by)
|
||||
"INSERT INTO resource (workspace_id, path, value, description, resource_type, extra_perms, edited_at, created_by, labels)
|
||||
SELECT $2, path,
|
||||
CASE WHEN $3::text IS NOT NULL AND resource_type = 'ai_agent'
|
||||
AND jsonb_typeof(value) = 'object' AND value ? 'on_behalf_of'
|
||||
THEN jsonb_set(value, '{on_behalf_of}', to_jsonb($3::text))
|
||||
ELSE value END,
|
||||
description, resource_type, extra_perms, edited_at, created_by
|
||||
description, resource_type, extra_perms, edited_at, created_by, labels
|
||||
FROM resource
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -8473,8 +8473,8 @@ async fn clone_variables(
|
||||
) -> Result<()> {
|
||||
// Dispatch markers are not copied, so the fork re-arms its own handler.
|
||||
sqlx::query!(
|
||||
"INSERT INTO variable (workspace_id, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until)
|
||||
SELECT $2, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until
|
||||
"INSERT INTO variable (workspace_id, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until, labels)
|
||||
SELECT $2, path, value, is_secret, description, extra_perms, account, is_oauth, expires_at, value_valid_until, labels
|
||||
FROM variable
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -8557,7 +8557,7 @@ async fn clone_scripts(
|
||||
dedicated_worker, ws_error_handler_muted, priority, timeout,
|
||||
delete_after_use, delete_after_secs, restart_unless_cancelled, concurrency_key,
|
||||
visible_to_runner_only, auto_kind, codebase, has_preprocessor,
|
||||
on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes
|
||||
on_behalf_of, on_behalf_of_email, assets, modules, job_token_scopes, labels
|
||||
)
|
||||
SELECT
|
||||
$1, hash, path, parent_hashes, summary, description, content,
|
||||
@@ -8589,7 +8589,7 @@ async fn clone_scripts(
|
||||
UNION ALL
|
||||
SELECT 1 FROM password p WHERE p.email = on_behalf_of
|
||||
AND p.super_admin))
|
||||
END, on_behalf_of_email, assets, modules, job_token_scopes
|
||||
END, on_behalf_of_email, assets, modules, job_token_scopes, labels
|
||||
FROM script
|
||||
WHERE workspace_id = $2"#,
|
||||
target_workspace_id,
|
||||
@@ -8992,7 +8992,7 @@ async fn clone_flows(
|
||||
archived, schema, extra_perms, dependency_job, tag,
|
||||
ws_error_handler_muted, dedicated_worker, timeout, visible_to_runner_only,
|
||||
concurrency_key, versions, on_behalf_of, on_behalf_of_email, lock_error_logs,
|
||||
job_token_scopes
|
||||
job_token_scopes, labels
|
||||
)
|
||||
SELECT $2, path, summary, description, value, edited_by, edited_at,
|
||||
archived, schema, extra_perms, NULL, tag,
|
||||
@@ -9018,7 +9018,7 @@ async fn clone_flows(
|
||||
UNION ALL
|
||||
SELECT 1 FROM password p WHERE p.email = on_behalf_of
|
||||
AND p.super_admin))
|
||||
END, on_behalf_of_email, lock_error_logs, job_token_scopes
|
||||
END, on_behalf_of_email, lock_error_logs, job_token_scopes, labels
|
||||
FROM flow
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -9125,7 +9125,7 @@ async fn clone_apps(
|
||||
let preserve_identity = windmill_common::can_preserve_on_behalf_of(authed);
|
||||
// Get all apps from source workspace
|
||||
let apps = sqlx::query!(
|
||||
"SELECT id, workspace_id, path, summary, policy, versions, extra_perms, custom_path
|
||||
"SELECT id, workspace_id, path, summary, policy, versions, extra_perms, custom_path, labels
|
||||
FROM app
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id
|
||||
@@ -9162,8 +9162,8 @@ async fn clone_apps(
|
||||
None
|
||||
};
|
||||
let new_app_id = sqlx::query_scalar!(
|
||||
"INSERT INTO app (workspace_id, path, summary, policy, versions, extra_perms, custom_path)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
"INSERT INTO app (workspace_id, path, summary, policy, versions, extra_perms, custom_path, labels)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id",
|
||||
target_workspace_id,
|
||||
app.path,
|
||||
@@ -9172,6 +9172,7 @@ async fn clone_apps(
|
||||
&Vec::<i64>::new(), // Start with empty versions array
|
||||
app.extra_perms,
|
||||
custom_path,
|
||||
app.labels.as_deref(),
|
||||
)
|
||||
.fetch_one(&mut **tx)
|
||||
.await?;
|
||||
@@ -9460,8 +9461,8 @@ async fn clone_raw_apps(
|
||||
target_workspace_id: &str,
|
||||
) -> Result<()> {
|
||||
sqlx::query!(
|
||||
"INSERT INTO raw_app (path, version, workspace_id, summary, edited_at, data, extra_perms)
|
||||
SELECT path, version, $2, summary, edited_at, data, extra_perms
|
||||
"INSERT INTO raw_app (path, version, workspace_id, summary, edited_at, data, extra_perms, labels)
|
||||
SELECT path, version, $2, summary, edited_at, data, extra_perms, labels
|
||||
FROM raw_app
|
||||
WHERE workspace_id = $1",
|
||||
source_workspace_id,
|
||||
@@ -14939,7 +14940,7 @@ async fn compare_two_scripts(
|
||||
) -> Result<ItemComparison> {
|
||||
// Get latest script from each workspace
|
||||
let source_script = sqlx::query!(
|
||||
"SELECT hash, created_at, content, summary, description, lock, schema
|
||||
"SELECT hash, created_at, content, summary, description, lock, schema, labels
|
||||
FROM script
|
||||
WHERE workspace_id = $1 AND path = $2 AND archived = false
|
||||
ORDER BY created_at DESC
|
||||
@@ -14951,7 +14952,7 @@ async fn compare_two_scripts(
|
||||
.await?;
|
||||
|
||||
let target_script = sqlx::query!(
|
||||
"SELECT hash, created_at, content, summary, description, lock, schema
|
||||
"SELECT hash, created_at, content, summary, description, lock, schema, labels
|
||||
FROM script
|
||||
WHERE workspace_id = $1 AND path = $2 AND archived = false
|
||||
ORDER BY created_at DESC
|
||||
@@ -14971,6 +14972,7 @@ async fn compare_two_scripts(
|
||||
|| source.description != target.description
|
||||
|| source.lock != target.lock
|
||||
|| source.schema != target.schema
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
}
|
||||
@@ -14994,7 +14996,7 @@ async fn compare_two_flows(
|
||||
) -> Result<ItemComparison> {
|
||||
// Get latest flow from each workspace
|
||||
let source_flow = sqlx::query!(
|
||||
"SELECT value, summary, description, schema
|
||||
"SELECT value, summary, description, schema, labels
|
||||
FROM flow
|
||||
WHERE workspace_id = $1 AND path = $2 AND archived = false",
|
||||
source_workspace_id,
|
||||
@@ -15004,7 +15006,7 @@ async fn compare_two_flows(
|
||||
.await?;
|
||||
|
||||
let target_flow = sqlx::query!(
|
||||
"SELECT value, summary, description, schema
|
||||
"SELECT value, summary, description, schema, labels
|
||||
FROM flow
|
||||
WHERE workspace_id = $1 AND path = $2 AND archived = false",
|
||||
fork_workspace_id,
|
||||
@@ -15021,6 +15023,7 @@ async fn compare_two_flows(
|
||||
|| source.summary != target.summary
|
||||
|| source.description != target.description
|
||||
|| source.schema != target.schema
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
}
|
||||
@@ -15062,7 +15065,7 @@ async fn compare_two_apps(
|
||||
// conversion is a change even when nothing else moved.
|
||||
// Get app with its latest version data from source workspace
|
||||
let source_app = sqlx::query!(
|
||||
"SELECT app.summary, app.policy, app_version.value, app_version.raw_app
|
||||
"SELECT app.summary, app.policy, app_version.value, app_version.raw_app, app.labels
|
||||
FROM app
|
||||
JOIN app_version
|
||||
ON app_version.id = app.versions[array_upper(app.versions, 1)]
|
||||
@@ -15074,7 +15077,7 @@ async fn compare_two_apps(
|
||||
.await?;
|
||||
|
||||
let target_app = sqlx::query!(
|
||||
"SELECT app.summary, app.policy, app_version.value, app_version.raw_app
|
||||
"SELECT app.summary, app.policy, app_version.value, app_version.raw_app, app.labels
|
||||
FROM app
|
||||
JOIN app_version
|
||||
ON app_version.id = app.versions[array_upper(app.versions, 1)]
|
||||
@@ -15093,6 +15096,7 @@ async fn compare_two_apps(
|
||||
|| without_identity(&source.policy) != without_identity(&target.policy)
|
||||
|| source.value != target.value
|
||||
|| source.raw_app != target.raw_app
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
}
|
||||
@@ -15114,6 +15118,11 @@ fn description_differs(a: &Option<String>, b: &Option<String>) -> bool {
|
||||
a.as_deref().unwrap_or("") != b.as_deref().unwrap_or("")
|
||||
}
|
||||
|
||||
// Cleared labels are stored as NULL by some writers and `{}` by others.
|
||||
fn labels_differ(a: &Option<Vec<String>>, b: &Option<Vec<String>>) -> bool {
|
||||
a.as_deref().unwrap_or_default() != b.as_deref().unwrap_or_default()
|
||||
}
|
||||
|
||||
async fn compare_two_resources(
|
||||
db: &DB,
|
||||
source_workspace_id: &str,
|
||||
@@ -15122,7 +15131,7 @@ async fn compare_two_resources(
|
||||
) -> Result<ItemComparison> {
|
||||
// Get resource from each workspace
|
||||
let source_resource = sqlx::query!(
|
||||
"SELECT value, description, resource_type
|
||||
"SELECT value, description, resource_type, labels
|
||||
FROM resource
|
||||
WHERE workspace_id = $1 AND path = $2",
|
||||
source_workspace_id,
|
||||
@@ -15132,7 +15141,7 @@ async fn compare_two_resources(
|
||||
.await?;
|
||||
|
||||
let target_resource = sqlx::query!(
|
||||
"SELECT value, description, resource_type
|
||||
"SELECT value, description, resource_type, labels
|
||||
FROM resource
|
||||
WHERE workspace_id = $1 AND path = $2",
|
||||
fork_workspace_id,
|
||||
@@ -15184,6 +15193,7 @@ async fn compare_two_resources(
|
||||
if values_differ
|
||||
|| description_differs(&source.description, &target.description)
|
||||
|| source.resource_type != target.resource_type
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
}
|
||||
@@ -15237,7 +15247,7 @@ async fn compare_two_variables(
|
||||
|
||||
// Get variable from each workspace
|
||||
let source_variable = sqlx::query!(
|
||||
"SELECT value::text AS \"value!\", is_secret, description, value_valid_until
|
||||
"SELECT value::text AS \"value!\", is_secret, description, value_valid_until, labels
|
||||
FROM variable
|
||||
WHERE workspace_id = $1 AND path = $2",
|
||||
source_workspace_id,
|
||||
@@ -15247,7 +15257,7 @@ async fn compare_two_variables(
|
||||
.await?;
|
||||
|
||||
let target_variable = sqlx::query!(
|
||||
"SELECT value::text AS \"value!\", is_secret, description, value_valid_until
|
||||
"SELECT value::text AS \"value!\", is_secret, description, value_valid_until, labels
|
||||
FROM variable
|
||||
WHERE workspace_id = $1 AND path = $2",
|
||||
fork_workspace_id,
|
||||
@@ -15263,6 +15273,7 @@ async fn compare_two_variables(
|
||||
if source.is_secret != target.is_secret
|
||||
|| source.description != target.description
|
||||
|| source.value_valid_until != target.value_valid_until
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
} else if source.value != target.value
|
||||
@@ -15354,7 +15365,7 @@ async fn compare_two_folders(
|
||||
) -> Result<ItemComparison> {
|
||||
// Get folder from each workspace
|
||||
let source_folder = sqlx::query!(
|
||||
"SELECT display_name, owners, extra_perms, summary
|
||||
"SELECT display_name, owners, extra_perms, summary, labels
|
||||
FROM folder
|
||||
WHERE workspace_id = $1 AND name = $2",
|
||||
source_workspace_id,
|
||||
@@ -15364,7 +15375,7 @@ async fn compare_two_folders(
|
||||
.await?;
|
||||
|
||||
let target_folder = sqlx::query!(
|
||||
"SELECT display_name, owners, extra_perms, summary
|
||||
"SELECT display_name, owners, extra_perms, summary, labels
|
||||
FROM folder
|
||||
WHERE workspace_id = $1 AND name = $2",
|
||||
fork_workspace_id,
|
||||
@@ -15381,6 +15392,7 @@ async fn compare_two_folders(
|
||||
|| source.owners != target.owners
|
||||
|| source.extra_perms != target.extra_perms
|
||||
|| source.summary != target.summary
|
||||
|| labels_differ(&source.labels, &target.labels)
|
||||
{
|
||||
has_changes = true;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,33 @@ test("deployItem: carries labels for variables, resources and folders", async ()
|
||||
}
|
||||
});
|
||||
|
||||
test("deployItem: keeps the target's labels when the source has none set", async () => {
|
||||
// Forks can hold items whose labels were never copied; only an explicit [] is a clear.
|
||||
for (const labels of [undefined, []]) {
|
||||
const bodies: any[] = [];
|
||||
const write = async (p: any) => void bodies.push(p.requestBody);
|
||||
const provider = {
|
||||
existsVariable: async () => true,
|
||||
existsResource: async () => true,
|
||||
existsFlowByPath: async () => true,
|
||||
existsApp: async () => true,
|
||||
getVariable: async () => ({ value: "v", is_secret: false, labels }),
|
||||
getResource: async () => ({ value: {}, resource_type: "postgresql", labels }),
|
||||
getFlowByPath: async () => ({ path: "f/x/i", value: { modules: [] }, labels }),
|
||||
getAppByPath: async () => ({ path: "f/x/i", policy: {}, labels }),
|
||||
updateVariable: write,
|
||||
updateResource: write,
|
||||
updateFlow: write,
|
||||
updateApp: write,
|
||||
} as any;
|
||||
for (const kind of ["variable", "resource", "flow", "app"]) {
|
||||
const result = await deployItem(provider, kind as any, "f/x/i", "src", "dst");
|
||||
expect(result).toEqual({ success: true });
|
||||
}
|
||||
expect(bodies.map((b) => b.labels)).toEqual([labels, labels, labels, labels]);
|
||||
}
|
||||
});
|
||||
|
||||
test("deployItem: carries a resource type's file settings and clears unset ones", async () => {
|
||||
const bodies: Record<string, any> = {};
|
||||
const deploy = (exists: boolean, rt: any) =>
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@windmill-labs/utils-internal",
|
||||
"version": "1.8.6",
|
||||
"version": "1.8.7",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@windmill-labs/utils-internal",
|
||||
"version": "1.8.6",
|
||||
"version": "1.8.7",
|
||||
"license": "Apache 2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.2.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@windmill-labs/utils-internal",
|
||||
"version": "1.8.6",
|
||||
"version": "1.8.7",
|
||||
"description": "Internal utility functions for Windmill",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
|
||||
@@ -624,6 +624,8 @@ export async function deployItem(
|
||||
value: variable.value ?? "",
|
||||
is_secret: variable.is_secret,
|
||||
description: variable.description ?? "",
|
||||
// No `?? []`: cleared labels read back as [], while absent ones may never have been
|
||||
// copied into the fork, so defaulting them would wipe the target's.
|
||||
labels: variable.labels,
|
||||
// `null` clears; absent would keep the target's stored date.
|
||||
value_valid_until: variable.value_valid_until ?? null,
|
||||
@@ -930,6 +932,7 @@ export async function getItemValue(
|
||||
schema: flow.schema,
|
||||
value: flow.value,
|
||||
job_token_scopes: flow.job_token_scopes ?? null,
|
||||
labels: flow.labels ?? [],
|
||||
};
|
||||
} else if (kind === "script") {
|
||||
const script = await provider.getScriptByPath({ workspace, path });
|
||||
@@ -941,9 +944,11 @@ export async function getItemValue(
|
||||
description: script.description,
|
||||
language: script.language,
|
||||
job_token_scopes: script.job_token_scopes ?? null,
|
||||
labels: script.labels ?? [],
|
||||
};
|
||||
} else if (kind === "app" || kind === "raw_app") {
|
||||
return await provider.getAppByPath({ workspace, path });
|
||||
const app = await provider.getAppByPath({ workspace, path });
|
||||
return { ...app, labels: app.labels ?? [] };
|
||||
} else if (kind === "variable") {
|
||||
const variable = await provider.getVariable({
|
||||
workspace,
|
||||
@@ -955,6 +960,7 @@ export async function getItemValue(
|
||||
is_secret: variable.is_secret,
|
||||
description: variable.description,
|
||||
value_valid_until: variable.value_valid_until ?? undefined,
|
||||
labels: variable.labels ?? [],
|
||||
};
|
||||
} else if (kind === "resource") {
|
||||
const resource = await provider.getResource({ workspace, path });
|
||||
@@ -968,6 +974,7 @@ export async function getItemValue(
|
||||
value,
|
||||
description: resource.description,
|
||||
resource_type: resource.resource_type,
|
||||
labels: resource.labels ?? [],
|
||||
};
|
||||
} else if (kind === "resource_type") {
|
||||
const rt = await provider.getResourceType({ workspace, path });
|
||||
@@ -988,6 +995,7 @@ export async function getItemValue(
|
||||
owners: folder.owners,
|
||||
extra_perms: folder.extra_perms,
|
||||
summary: folder.summary,
|
||||
labels: folder.labels ?? [],
|
||||
};
|
||||
} else if (kind === "schedule") {
|
||||
// Mirror the runtime-fields-ignore set used server-side so the diff drawer
|
||||
|
||||
Reference in New Issue
Block a user