|
@@ -1,13 +1,9 @@
|
|
|
-import {
|
|
|
|
|
- BUILDPACK_TO_NAME,
|
|
|
|
|
- buildpackSchema,
|
|
|
|
|
-} from "main/home/app-dashboard/types/buildpack";
|
|
|
|
|
|
|
+import { BUILDPACK_TO_NAME } from "main/home/app-dashboard/types/buildpack";
|
|
|
import { z } from "zod";
|
|
import { z } from "zod";
|
|
|
import {
|
|
import {
|
|
|
DetectedServices,
|
|
DetectedServices,
|
|
|
defaultSerialized,
|
|
defaultSerialized,
|
|
|
deserializeService,
|
|
deserializeService,
|
|
|
- isPredeployService,
|
|
|
|
|
serializeService,
|
|
serializeService,
|
|
|
serializedServiceFromProto,
|
|
serializedServiceFromProto,
|
|
|
serviceProto,
|
|
serviceProto,
|
|
@@ -16,22 +12,7 @@ import {
|
|
|
import { Build, PorterApp, Service } from "@porter-dev/api-contracts";
|
|
import { Build, PorterApp, Service } from "@porter-dev/api-contracts";
|
|
|
import { match } from "ts-pattern";
|
|
import { match } from "ts-pattern";
|
|
|
import { KeyValueType } from "main/home/cluster-dashboard/env-groups/EnvGroupArray";
|
|
import { KeyValueType } from "main/home/cluster-dashboard/env-groups/EnvGroupArray";
|
|
|
-
|
|
|
|
|
-// buildValidator is used to validate inputs for build setting fields
|
|
|
|
|
-export const buildValidator = z.discriminatedUnion("method", [
|
|
|
|
|
- z.object({
|
|
|
|
|
- method: z.literal("pack"),
|
|
|
|
|
- context: z.string().default("./"),
|
|
|
|
|
- buildpacks: z.array(buildpackSchema).default([]),
|
|
|
|
|
- builder: z.string(),
|
|
|
|
|
- }),
|
|
|
|
|
- z.object({
|
|
|
|
|
- method: z.literal("docker"),
|
|
|
|
|
- context: z.string().default("./"),
|
|
|
|
|
- dockerfile: z.string().default("./Dockerfile"),
|
|
|
|
|
- }),
|
|
|
|
|
-]);
|
|
|
|
|
-export type BuildOptions = z.infer<typeof buildValidator>;
|
|
|
|
|
|
|
+import { BuildOptions, buildValidator } from "./build";
|
|
|
|
|
|
|
|
// sourceValidator is used to validate inputs for source setting fields
|
|
// sourceValidator is used to validate inputs for source setting fields
|
|
|
export const sourceValidator = z.discriminatedUnion("type", [
|
|
export const sourceValidator = z.discriminatedUnion("type", [
|
|
@@ -117,7 +98,10 @@ export function serviceOverrides({
|
|
|
.map((svc) => {
|
|
.map((svc) => {
|
|
|
if (useDefaults) {
|
|
if (useDefaults) {
|
|
|
return deserializeService({
|
|
return deserializeService({
|
|
|
- service: defaultSerialized({ name: svc.name, type: svc.config.type }),
|
|
|
|
|
|
|
+ service: defaultSerialized({
|
|
|
|
|
+ name: svc.name,
|
|
|
|
|
+ type: svc.config.type,
|
|
|
|
|
+ }),
|
|
|
override: svc,
|
|
override: svc,
|
|
|
expanded: true,
|
|
expanded: true,
|
|
|
});
|
|
});
|
|
@@ -126,6 +110,15 @@ export function serviceOverrides({
|
|
|
return deserializeService({ service: svc });
|
|
return deserializeService({ service: svc });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const validatedBuild = buildValidator
|
|
|
|
|
+ .default({
|
|
|
|
|
+ method: "pack",
|
|
|
|
|
+ context: "./",
|
|
|
|
|
+ buildpacks: [],
|
|
|
|
|
+ builder: "",
|
|
|
|
|
+ })
|
|
|
|
|
+ .parse(overrides.build);
|
|
|
|
|
+
|
|
|
if (!overrides.predeploy) {
|
|
if (!overrides.predeploy) {
|
|
|
return {
|
|
return {
|
|
|
services,
|
|
services,
|
|
@@ -134,6 +127,7 @@ export function serviceOverrides({
|
|
|
|
|
|
|
|
if (useDefaults) {
|
|
if (useDefaults) {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ build: validatedBuild,
|
|
|
services,
|
|
services,
|
|
|
predeploy: deserializeService({
|
|
predeploy: deserializeService({
|
|
|
service: defaultSerialized({
|
|
service: defaultSerialized({
|
|
@@ -151,6 +145,7 @@ export function serviceOverrides({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
|
|
+ build: validatedBuild,
|
|
|
services,
|
|
services,
|
|
|
predeploy: deserializeService({
|
|
predeploy: deserializeService({
|
|
|
service: serializedServiceFromProto({
|
|
service: serializedServiceFromProto({
|