@miosa/sdk 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +41 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/resources/deployments.test.ts +73 -0
- package/src/resources/deployments.ts +58 -5
package/dist/index.js
CHANGED
|
@@ -3652,6 +3652,22 @@ function dockerDeployHostId(deployment) {
|
|
|
3652
3652
|
const metadataHost = deployment.metadata?.["docker_deploy_host_id"];
|
|
3653
3653
|
return deployment.docker_deploy_host_id ?? (typeof metadataHost === "string" ? metadataHost : null);
|
|
3654
3654
|
}
|
|
3655
|
+
function dockerDeployApp(deployment) {
|
|
3656
|
+
const app = deployment.metadata?.["docker_deploy"];
|
|
3657
|
+
if (!app || typeof app !== "object" || Array.isArray(app)) return null;
|
|
3658
|
+
return app;
|
|
3659
|
+
}
|
|
3660
|
+
function dockerDeployAppPort(app) {
|
|
3661
|
+
const url = app?.["url"];
|
|
3662
|
+
if (typeof url !== "string") return null;
|
|
3663
|
+
try {
|
|
3664
|
+
const parsed = new URL(url);
|
|
3665
|
+
const port = Number.parseInt(parsed.port, 10);
|
|
3666
|
+
return Number.isInteger(port) ? port : null;
|
|
3667
|
+
} catch {
|
|
3668
|
+
return null;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3655
3671
|
function addDoctorCheck(checks, name, ok, message, details) {
|
|
3656
3672
|
checks.push({ name, ok, message, ...details ? { details } : {} });
|
|
3657
3673
|
}
|
|
@@ -3909,14 +3925,36 @@ var Deployments = class {
|
|
|
3909
3925
|
);
|
|
3910
3926
|
}
|
|
3911
3927
|
}
|
|
3928
|
+
const app = dockerDeployApp(deployment);
|
|
3929
|
+
const appPort = dockerDeployAppPort(app);
|
|
3930
|
+
const appRunning = app?.["status"] === "running" && appPort !== null;
|
|
3931
|
+
addDoctorCheck(
|
|
3932
|
+
checks,
|
|
3933
|
+
"docker_deploy_app",
|
|
3934
|
+
appRunning,
|
|
3935
|
+
appRunning ? "Docker Deploy app metadata points at a running container." : "Deployment is missing running Docker Deploy app metadata.",
|
|
3936
|
+
app ? {
|
|
3937
|
+
app_id: app["app_id"],
|
|
3938
|
+
container_id: app["container_id"],
|
|
3939
|
+
status: app["status"],
|
|
3940
|
+
url: app["url"],
|
|
3941
|
+
expected_port: appPort
|
|
3942
|
+
} : void 0
|
|
3943
|
+
);
|
|
3912
3944
|
const runtime = metadata["runtime"];
|
|
3913
3945
|
const hasRuntimeRoute = typeof runtime === "object" && runtime !== null && typeof runtime["ip"] === "string" && typeof runtime["port"] === "number";
|
|
3946
|
+
const runtimeRecord = hasRuntimeRoute && typeof runtime === "object" ? runtime : void 0;
|
|
3947
|
+
const routeMatchesContainerPort = hasRuntimeRoute && (appPort === null || runtimeRecord?.["port"] === appPort);
|
|
3914
3948
|
addDoctorCheck(
|
|
3915
3949
|
checks,
|
|
3916
3950
|
"runtime_route",
|
|
3917
|
-
hasRuntimeRoute,
|
|
3918
|
-
hasRuntimeRoute ? "Deployment
|
|
3919
|
-
|
|
3951
|
+
hasRuntimeRoute && routeMatchesContainerPort,
|
|
3952
|
+
hasRuntimeRoute && routeMatchesContainerPort ? "Deployment route points at the Docker container host port." : hasRuntimeRoute && appPort !== null ? `Deployment route port ${String(runtimeRecord?.["port"])} does not match Docker container host port ${appPort}.` : "Deployment is missing appliance runtime route metadata.",
|
|
3953
|
+
runtimeRecord ? {
|
|
3954
|
+
...runtimeRecord,
|
|
3955
|
+
expected_port: appPort,
|
|
3956
|
+
docker_deploy_url: app?.["url"]
|
|
3957
|
+
} : void 0
|
|
3920
3958
|
);
|
|
3921
3959
|
let probe;
|
|
3922
3960
|
const publicUrl = deployment.public_url;
|