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.startsWith("unix://")) {
|
||||
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 };
|
||||
}
|
||||
if (url.startsWith("/")) return { socketPath: url };
|
||||
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;
|
||||
if (!username)
|
||||
throw new AppError({
|
||||
message: "SSH Docker host URL requires a user: ssh://user@host",
|
||||
status: 422,
|
||||
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 {
|
||||
protocol: "ssh",
|
||||
|
||||
@@ -97,7 +97,7 @@ export interface HardwareStatusPayload {
|
||||
}
|
||||
|
||||
// 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 const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;
|
||||
|
||||
Reference in new issue
Block a user