feat: release 2.7.0-rc3
This commit is contained in:
+13
-5
@@ -11,6 +11,7 @@ import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { YAML } from "bun";
|
||||
import type { Service } from "../schema/docker.d";
|
||||
import { validateBuildpackUri } from "../shared/build-protocol";
|
||||
import { readCompose, resolveComposeFile } from "./yaml";
|
||||
import {
|
||||
renderDockerfileTemplate,
|
||||
@@ -44,7 +45,7 @@ const serviceNamePattern = /^[a-z][a-z0-9-]*$/;
|
||||
|
||||
export type Source =
|
||||
| { kind: "image"; image: string }
|
||||
| { kind: "auto" }
|
||||
| { kind: "auto"; uri?: string }
|
||||
| { kind: "template"; template: DockerfileTemplateId };
|
||||
export type AppOptions = {
|
||||
name: string;
|
||||
@@ -131,12 +132,19 @@ export function serviceForApp(app: AppOptions): Service {
|
||||
if (!app.source.image.trim()) throw new Error("Image must not be empty");
|
||||
service.image = app.source.image.trim();
|
||||
} else {
|
||||
if (app.source.kind === "auto" && app.source.uri?.trim())
|
||||
validateBuildpackUri(app.source.uri.trim());
|
||||
if (
|
||||
app.source.kind === "template" &&
|
||||
!templateIds.includes(app.source.template)
|
||||
)
|
||||
throw new Error(`Unknown Dockerfile template: ${app.source.template}`);
|
||||
service.build = app.source.kind === "auto" ? "auto" : path;
|
||||
service.build =
|
||||
app.source.kind === "auto"
|
||||
? app.source.uri?.trim()
|
||||
? `auto:${app.source.uri.trim()}`
|
||||
: "auto"
|
||||
: path;
|
||||
if (app.source.kind === "auto" && path !== ".")
|
||||
service["x-kuber-build-context"] = path;
|
||||
}
|
||||
@@ -221,13 +229,13 @@ export async function addAppToCompose(
|
||||
throw new Error("Compose file cannot be found. Run kuber init first.");
|
||||
await checkedAppPath(root, app.path);
|
||||
const service = serviceForApp(app);
|
||||
const compose = await readCompose(path);
|
||||
if (Object.hasOwn(compose.services ?? {}, app.name))
|
||||
throw new Error(`Service ${app.name} already exists`);
|
||||
const generated: string[] = [];
|
||||
const lock = await open(`${path}.kuber.lock`, "wx");
|
||||
try {
|
||||
const original = await readFile(path, "utf8");
|
||||
const compose = await readCompose(path);
|
||||
if (Object.hasOwn(compose.services ?? {}, app.name))
|
||||
throw new Error(`Service ${app.name} already exists`);
|
||||
const source = app.source;
|
||||
if (source.kind === "template") {
|
||||
const templates = renderDockerfileTemplate(source.template);
|
||||
|
||||
Reference in New Issue
Block a user