mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 16:05:42 +00:00
fix: cli: support deleting linked resources-variables without throwing (#8248)
This commit is contained in:
@@ -2626,6 +2626,7 @@ export async function push(
|
||||
let [_basePath, changes] = queue.shift()!;
|
||||
const promise = (async () => {
|
||||
const alreadySynced: string[] = [];
|
||||
const deletedVarsResPaths: string[] = [];
|
||||
const isRawApp = isRawAppFile(changes[0].path);
|
||||
if (isRawApp) {
|
||||
const deleteRawApp = changes.find(
|
||||
@@ -2870,12 +2871,23 @@ export async function push(
|
||||
name: change.path.split(SEP)[1],
|
||||
});
|
||||
break;
|
||||
case "resource":
|
||||
await wmill.deleteResource({
|
||||
workspace: workspaceId,
|
||||
path: removeSuffix(target, ".resource.json"),
|
||||
});
|
||||
case "resource": {
|
||||
const resourcePath = removeSuffix(target, ".resource.json");
|
||||
try {
|
||||
await wmill.deleteResource({
|
||||
workspace: workspaceId,
|
||||
path: resourcePath,
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e?.status === 404 && deletedVarsResPaths.includes(resourcePath)) {
|
||||
log.debug(`Resource ${resourcePath} already deleted by linked variable`);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
deletedVarsResPaths.push(resourcePath);
|
||||
break;
|
||||
}
|
||||
case "resource-type":
|
||||
await wmill.deleteResourceType({
|
||||
workspace: workspaceId,
|
||||
@@ -3012,12 +3024,23 @@ export async function push(
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "variable":
|
||||
await wmill.deleteVariable({
|
||||
workspace: workspaceId,
|
||||
path: removeSuffix(target, ".variable.json"),
|
||||
});
|
||||
case "variable": {
|
||||
const variablePath = removeSuffix(target, ".variable.json");
|
||||
try {
|
||||
await wmill.deleteVariable({
|
||||
workspace: workspaceId,
|
||||
path: variablePath,
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e?.status === 404 && deletedVarsResPaths.includes(variablePath)) {
|
||||
log.debug(`Variable ${variablePath} already deleted by linked resource`);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
deletedVarsResPaths.push(variablePath);
|
||||
break;
|
||||
}
|
||||
case "user": {
|
||||
const users = await wmill.listUsers({
|
||||
workspace: workspaceId,
|
||||
|
||||
Reference in New Issue
Block a user