|
|
|
@ -1,6 +1,5 @@
|
|
|
|
import type { IEditServiceForm, IServiceNodeItem } from "../../../types";
|
|
|
|
import type { IEditServiceForm, IServiceNodeItem } from "../../../types";
|
|
|
|
import * as yup from "yup";
|
|
|
|
import * as yup from "yup";
|
|
|
|
import lodash from "lodash";
|
|
|
|
|
|
|
|
import { checkArray } from "../../../utils/forms";
|
|
|
|
import { checkArray } from "../../../utils/forms";
|
|
|
|
|
|
|
|
|
|
|
|
const initialValues: IEditServiceForm = {
|
|
|
|
const initialValues: IEditServiceForm = {
|
|
|
|
@ -153,51 +152,41 @@ export const getFinalValues = (
|
|
|
|
): IServiceNodeItem => {
|
|
|
|
): IServiceNodeItem => {
|
|
|
|
const { environmentVariables, ports, volumes, labels } = values;
|
|
|
|
const { environmentVariables, ports, volumes, labels } = values;
|
|
|
|
|
|
|
|
|
|
|
|
return lodash.mergeWith(
|
|
|
|
return {
|
|
|
|
lodash.cloneDeep(previous) || {
|
|
|
|
key: previous?.key ?? "service",
|
|
|
|
key: "service",
|
|
|
|
type: "SERVICE",
|
|
|
|
type: "SERVICE",
|
|
|
|
inputs: previous?.inputs ?? ["op_source"],
|
|
|
|
inputs: ["op_source"],
|
|
|
|
outputs: previous?.outputs ?? [],
|
|
|
|
outputs: [],
|
|
|
|
config: (previous as any)?.config ?? {},
|
|
|
|
config: {}
|
|
|
|
canvasConfig: {
|
|
|
|
},
|
|
|
|
node_name: values.serviceName
|
|
|
|
{
|
|
|
|
|
|
|
|
canvasConfig: {
|
|
|
|
|
|
|
|
node_name: values.serviceName
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
serviceConfig: {
|
|
|
|
|
|
|
|
image: `${values.imageName}${
|
|
|
|
|
|
|
|
values.imageTag ? `:${values.imageTag}` : ""
|
|
|
|
|
|
|
|
}`,
|
|
|
|
|
|
|
|
container_name: values.containerName,
|
|
|
|
|
|
|
|
environment: environmentVariables.map(
|
|
|
|
|
|
|
|
(variable) =>
|
|
|
|
|
|
|
|
`${variable.key}${variable.value ? `=${variable.value}` : ""}`
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
volumes: volumes.length
|
|
|
|
|
|
|
|
? volumes.map(
|
|
|
|
|
|
|
|
(volume) =>
|
|
|
|
|
|
|
|
volume.name +
|
|
|
|
|
|
|
|
(volume.containerPath ? `:${volume.containerPath}` : "") +
|
|
|
|
|
|
|
|
(volume.accessMode ? `:${volume.accessMode}` : "")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: [],
|
|
|
|
|
|
|
|
ports: ports.map(
|
|
|
|
|
|
|
|
(port) =>
|
|
|
|
|
|
|
|
port.hostPort +
|
|
|
|
|
|
|
|
(port.containerPort ? `:${port.containerPort}` : "") +
|
|
|
|
|
|
|
|
(port.protocol ? `/${port.protocol}` : "")
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
labels: labels.map(
|
|
|
|
|
|
|
|
(label) => `${label.key}${label.value ? `=${label.value}` : ""}`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
(obj, src) => {
|
|
|
|
serviceConfig: {
|
|
|
|
if (!lodash.isNil(src)) {
|
|
|
|
image: `${values.imageName}${
|
|
|
|
return src;
|
|
|
|
values.imageTag ? `:${values.imageTag}` : ""
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
return obj;
|
|
|
|
container_name: values.containerName,
|
|
|
|
|
|
|
|
environment: environmentVariables.map(
|
|
|
|
|
|
|
|
(variable) =>
|
|
|
|
|
|
|
|
`${variable.key}${variable.value ? `=${variable.value}` : ""}`
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
volumes: volumes.length
|
|
|
|
|
|
|
|
? volumes.map(
|
|
|
|
|
|
|
|
(volume) =>
|
|
|
|
|
|
|
|
volume.name +
|
|
|
|
|
|
|
|
(volume.containerPath ? `:${volume.containerPath}` : "") +
|
|
|
|
|
|
|
|
(volume.accessMode ? `:${volume.accessMode}` : "")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: [],
|
|
|
|
|
|
|
|
ports: ports.map(
|
|
|
|
|
|
|
|
(port) =>
|
|
|
|
|
|
|
|
port.hostPort +
|
|
|
|
|
|
|
|
(port.containerPort ? `:${port.containerPort}` : "") +
|
|
|
|
|
|
|
|
(port.protocol ? `/${port.protocol}` : "")
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
labels: labels.map(
|
|
|
|
|
|
|
|
(label) => `${label.key}${label.value ? `=${label.value}` : ""}`
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) as any;
|
|
|
|
} as any;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|