mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-02 00:36:38 +00:00
Fix empty blueprint
This commit is contained in:
@@ -29,6 +29,23 @@ export async function applyNewtDockerBlueprint(
|
|||||||
|
|
||||||
logger.debug(`Received Docker blueprint: ${JSON.stringify(blueprint)}`);
|
logger.debug(`Received Docker blueprint: ${JSON.stringify(blueprint)}`);
|
||||||
|
|
||||||
|
// make sure this is not an empty object
|
||||||
|
if (isEmptyObject(blueprint)) {
|
||||||
|
throw new Error("No valid blueprint data found in container labels");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmptyObject(blueprint["proxy-resources"])) {
|
||||||
|
throw new Error(
|
||||||
|
"No proxy-resources found in blueprint data from container labels"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmptyObject(blueprint["client-resources"])) {
|
||||||
|
throw new Error(
|
||||||
|
"No client-resources found in blueprint data from container labels"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the blueprint in the database
|
// Update the blueprint in the database
|
||||||
await applyBlueprint({
|
await applyBlueprint({
|
||||||
orgId: site.orgId,
|
orgId: site.orgId,
|
||||||
@@ -42,7 +59,7 @@ export async function applyNewtDockerBlueprint(
|
|||||||
type: "newt/blueprint/results",
|
type: "newt/blueprint/results",
|
||||||
data: {
|
data: {
|
||||||
success: false,
|
success: false,
|
||||||
message: `Failed to update database from config: ${error}`
|
message: `Failed to apply blueprint from config: ${error}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -56,3 +73,10 @@ export async function applyNewtDockerBlueprint(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isEmptyObject(obj: any) {
|
||||||
|
if (obj === null || obj === undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user