0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/manager/docker-compose/schema.ts
Kyle Harding 5585818323
fix(manager/docker-compose): Allow strings or objects for service build (#27594)
Signed-off-by: Kyle Harding <kyle@balena.io>
2024-02-27 19:40:27 +00:00

27 lines
780 B
TypeScript

import { z } from 'zod';
const DockerComposeService = z.object({
image: z.string().optional(),
build: z
.union([
z.string(),
z.object({
context: z.string().optional(),
dockerfile: z.string().optional(),
}),
])
.optional(),
});
const DockerComposeFileV1 = z.record(DockerComposeService);
const DockerComposeFileModern = z.object({
// compose does not use this strictly, so we shouldn't be either
// https://docs.docker.com/compose/compose-file/04-version-and-name/#version-top-level-element
version: z.string().optional(),
services: z.record(DockerComposeService),
});
export const DockerComposeFile =
DockerComposeFileModern.or(DockerComposeFileV1);
export type DockerComposeFile = z.infer<typeof DockerComposeFile>;