refactor: change inspect functtions to get functions

This commit is contained in:
CyberL1 2025-01-07 10:56:05 +01:00
parent 928bc2f15e
commit 77ce186675
4 changed files with 11 additions and 9 deletions

View File

@ -1,9 +1,10 @@
import type { Container } from "#src/types/Container.ts"; import type { Container } from "#src/types/Container.ts";
import { inspectContainer } from "#src/utils/containers.ts"; import { getContainer } from "#src/utils/containers.ts";
import type { FastifyInstance, FastifyRequest } from "fastify"; import type { FastifyInstance, FastifyRequest } from "fastify";
export default (fastify: FastifyInstance) => { export default (fastify: FastifyInstance) => {
fastify.get("/", (req: FastifyRequest<{ Params: Container }>) => { fastify.get("/", (req: FastifyRequest<{ Params: Container }>) => {
return inspectContainer(req.params.id); const container = getContainer(req.params.id);
return container.inspect();
}); });
}; };

View File

@ -1,9 +1,10 @@
import type { Image } from "#src/types.ts"; import type { Image } from "#src/types/Image.ts";
import { inspectImage } from "#src/utils/images.ts"; import { getImage } from "#src/utils/images.ts";
import type { FastifyInstance, FastifyRequest } from "fastify"; import type { FastifyInstance, FastifyRequest } from "fastify";
export default (fastify: FastifyInstance) => { export default (fastify: FastifyInstance) => {
fastify.get("/", (req: FastifyRequest<{ Params: Image }>) => { fastify.get("/", (req: FastifyRequest<{ Params: Image }>) => {
return inspectImage(req.params.name); const image = getImage(req.params.name);
return image.inspect();
}); });
}; };

View File

@ -12,9 +12,9 @@ export const getContainers = () => {
return containers; return containers;
}; };
export const inspectContainer = (id: string) => { export const getContainer = (id: string) => {
const container = dockerode.getContainer(id); const container = dockerode.getContainer(id);
return container.inspect(); return container;
}; };
export const createContainer = ({ image }: CreateContainerBody) => { export const createContainer = ({ image }: CreateContainerBody) => {

View File

@ -10,7 +10,7 @@ export const getImages = () => {
return images; return images;
}; };
export const inspectImage = async (name: string) => { export const getImage = (name: string) => {
const image = dockerode.getImage(`code-containers/${name}`); const image = dockerode.getImage(`code-containers/${name}`);
return image.inspect(); return image;
}; };