add missing const, add key check
This commit is contained in:
1 parent
1ca38a31c9
commit
8f6c909acd
2 files changed
+13
-4
No files matched your search
@@ -47,19 +47,28 @@ export class DockerProvider implements IStatusProvider<DockerStatusPayload> {
|
|||||||
if (!url) throw new AppError({ message: "Docker host URL is required", status: 422, service: SERVICE_NAME, method: "toDockerOptions" });
|
if (!url) throw new AppError({ message: "Docker host URL is required", status: 422, service: SERVICE_NAME, method: "toDockerOptions" });
|
||||||
if (url.startsWith("unix://")) {
|
if (url.startsWith("unix://")) {
|
||||||
const socketPath = url.slice("unix://".length);
|
const socketPath = url.slice("unix://".length);
|
||||||
if (!socketPath.startsWith("/")) throw new Error(`Invalid Docker host URL: ${url}`);
|
if (!socketPath.startsWith("/"))
|
||||||
|
throw new AppError({ message: `Invalid Docker host URL: ${url}`, status: 422, service: SERVICE_NAME, method: "toDockerOptions" });
|
||||||
return { socketPath };
|
return { socketPath };
|
||||||
}
|
}
|
||||||
if (url.startsWith("/")) return { socketPath: url };
|
if (url.startsWith("/")) return { socketPath: url };
|
||||||
const match = url.match(/^ssh:\/\/(?:([^@\s]+)@)?([^\s/:@]+)(?::(\d{1,5}))?\/?$/);
|
const match = url.match(/^ssh:\/\/(?:([^@\s]+)@)?([^\s/:@]+)(?::(\d{1,5}))?\/?$/);
|
||||||
if (!match) throw new AppError({ message: "Invalid Docker host URL", status: 422, service: SERVICE_NAME, method: "toDockerOptions" });
|
if (!match) throw new AppError({ message: `Invalid Docker host URL: ${url}`, status: 422, service: SERVICE_NAME, method: "toDockerOptions" });
|
||||||
const [, username, host, port] = match;
|
const [, username, host, port] = match;
|
||||||
if (!username)
|
if (!username)
|
||||||
throw new AppError({
|
throw new AppError({
|
||||||
message: "SSH Docker host URL requires a user: ssh://user@host",
|
message: "SSH Docker host URL requires a user: ssh://user@host",
|
||||||
status: 422,
|
status: 422,
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "ToDockerOptions",
|
method: "toDockerOptions",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!monitor.sshPrivateKey)
|
||||||
|
throw new AppError({
|
||||||
|
message: "SSH Docker host requires a private key",
|
||||||
|
status: 422,
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
method: "toDockerOptions",
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
protocol: "ssh",
|
protocol: "ssh",
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export interface HardwareStatusPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Docker host monitoring
|
// Docker host monitoring
|
||||||
export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"];
|
export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"] as const;
|
||||||
export type DockerContainerState = (typeof DockerContainerStates)[number];
|
export type DockerContainerState = (typeof DockerContainerStates)[number];
|
||||||
|
|
||||||
export const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;
|
export const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;
|
||||||
|
|||||||
Reference in new issue
Block a user