mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-11 08:01:13 +00:00
start setting up action messages
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
|
||||
const CREATE_BUILD = "CREATE_BUILD";
|
||||
const DELETE_BUILD = "DELETE_BUILD";
|
||||
const UPDATE_BUILD = "UPDATE_BUILD";
|
||||
const PULL = "PULL";
|
||||
const BUILD = "BUILD";
|
||||
|
||||
async function buildMessages(app: FastifyInstance, type: string, message: any, permissions: number) {
|
||||
switch (type) {
|
||||
case CREATE_BUILD:
|
||||
return true;
|
||||
|
||||
case DELETE_BUILD:
|
||||
return true;
|
||||
|
||||
case UPDATE_BUILD:
|
||||
return true;
|
||||
|
||||
case PULL:
|
||||
return true;
|
||||
|
||||
case BUILD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default buildMessages;
|
||||
@@ -0,0 +1,62 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
|
||||
const CREATE_DEPLOYMENT = "CREATE_DEPLOYMENT";
|
||||
const DELETE_DEPLOYMENT = "DELETE_DEPLOYMENT";
|
||||
const UPDATE_DEPLOYMENT = "UPDATE_DEPLOYMENT";
|
||||
const DEPLOY = "DEPLOY";
|
||||
const REDEPLOY = "REDEPLOY";
|
||||
const START_CONTAINER = "START_CONTAINER";
|
||||
const STOP_CONTAINER = "STOP_CONTAINER";
|
||||
const DELETE_CONTAINER = "DELETE_CONTAINER";
|
||||
const REFRESH_CONTAINER_STATUS = "REFRESH_CONTAINER_STATUS";
|
||||
const COPY_ENV = "COPY_ENV";
|
||||
|
||||
const DEPLOY_TIMEOUT = 1000;
|
||||
const DEPLOY_RECHECK_TIMEOUT = 3000;
|
||||
|
||||
async function deploymentMessages(
|
||||
app: FastifyInstance,
|
||||
type: string,
|
||||
message: any,
|
||||
permissions: number
|
||||
) {
|
||||
switch (type) {
|
||||
case CREATE_DEPLOYMENT:
|
||||
return true;
|
||||
|
||||
case DELETE_DEPLOYMENT:
|
||||
return true;
|
||||
|
||||
case UPDATE_DEPLOYMENT:
|
||||
return true;
|
||||
|
||||
case DEPLOY:
|
||||
return true;
|
||||
|
||||
case REDEPLOY:
|
||||
return true;
|
||||
|
||||
case START_CONTAINER:
|
||||
return true;
|
||||
|
||||
case STOP_CONTAINER:
|
||||
return true;
|
||||
|
||||
case UPDATE_DEPLOYMENT:
|
||||
return true;
|
||||
|
||||
case DELETE_CONTAINER:
|
||||
return true;
|
||||
|
||||
case REFRESH_CONTAINER_STATUS:
|
||||
return true;
|
||||
|
||||
case COPY_ENV:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default deploymentMessages;
|
||||
@@ -1,5 +1,16 @@
|
||||
import { Action } from "@monitor/types";
|
||||
import { FastifyInstance } from "fastify";
|
||||
import buildMessages from "./build";
|
||||
import deploymentMessages from "./deployment";
|
||||
import serverMessages from "./server";
|
||||
|
||||
export default function handleMessage(app: FastifyInstance, message: object) {
|
||||
|
||||
}
|
||||
export default async function handleMessage(
|
||||
app: FastifyInstance,
|
||||
message: Action & object
|
||||
) {
|
||||
// handle permissions here
|
||||
const permissions = 0;
|
||||
(await buildMessages(app, message.type, message, permissions)) ||
|
||||
(await deploymentMessages(app, message.type, message, permissions)) ||
|
||||
(await serverMessages(app, message.type, message, permissions));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
|
||||
const ADD_SERVER = "ADD_SERVER";
|
||||
const REMOVE_SERVER = "REMOVE_SERVER";
|
||||
const UPDATE_SERVER = "UPDATE_SERVER";
|
||||
const PRUNE_SERVER = "PRUNE_SERVER";
|
||||
const GET_SERVER_STATS = "GET_SERVER_STATS";
|
||||
|
||||
async function serverMessages(
|
||||
app: FastifyInstance,
|
||||
type: string,
|
||||
message: any,
|
||||
permissions: number
|
||||
) {
|
||||
switch (type) {
|
||||
case ADD_SERVER:
|
||||
return true;
|
||||
|
||||
case REMOVE_SERVER:
|
||||
return true;
|
||||
|
||||
case UPDATE_SERVER:
|
||||
return true;
|
||||
|
||||
case PRUNE_SERVER:
|
||||
return true;
|
||||
|
||||
case GET_SERVER_STATS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default serverMessages;
|
||||
Reference in New Issue
Block a user