feat(frontend): updated `getFinalValues` to prune `deploy` object

pull/85/head
Samuel Rowe 3 years ago
parent 029cf06c79
commit a0e400fb4b

@ -6,7 +6,8 @@ import {
pruneObject, pruneObject,
extractObjectOrArray, extractObjectOrArray,
extractArray, extractArray,
pruneString pruneString,
pruneNumber
} from "../../../utils/forms"; } from "../../../utils/forms";
export const tabs = [ export const tabs = [
@ -57,8 +58,8 @@ const initialValues: IEditServiceForm = {
target: "" target: ""
}, },
deploy: { deploy: {
mode: "replicated", mode: "",
replicas: "1", replicas: "",
endpointMode: "", endpointMode: "",
placement: { placement: {
constraints: [], constraints: [],
@ -425,7 +426,7 @@ export const getFinalValues = (
}, },
serviceConfig: { serviceConfig: {
build: pruneObject({ build: pruneObject({
context: build.context, context: pruneString(build.context),
dockerfile: pruneString(build.dockerfile), dockerfile: pruneString(build.dockerfile),
args: pruneObject(build.arguments), args: pruneObject(build.arguments),
ssh: pruneArray( ssh: pruneArray(
@ -447,31 +448,31 @@ export const getFinalValues = (
target: pruneString(build.target) target: pruneString(build.target)
}), }),
deploy: pruneObject({ deploy: pruneObject({
mode: deploy.mode, mode: pruneString(deploy.mode),
replicas: deploy.replicas, replicas: pruneString(deploy.replicas),
endpoint_mode: deploy.endpointMode, endpoint_mode: pruneString(deploy.endpointMode),
placement: pruneObject({ placement: pruneObject({
constraints: pruneArray(deploy.placement.constraints), constraints: pruneArray(deploy.placement.constraints),
preferences: pruneArray(deploy.placement.preferences) preferences: pruneArray(deploy.placement.preferences)
}), }),
resources: pruneObject({ resources: pruneObject({
limits: pruneObject({ limits: pruneObject({
cpus: deploy.resources.limits.cpus, cpus: pruneString(deploy.resources.limits.cpus),
memory: deploy.resources.limits.memory, memory: pruneString(deploy.resources.limits.memory),
// NOTE: Could be a potential bug. // NOTE: Could be a potential bug.
pids: parseInt(deploy.resources.limits.pids) ?? undefined pids: pruneNumber(parseInt(deploy.resources.limits.pids))
}), }),
reservations: pruneObject({ reservations: pruneObject({
cpus: deploy.resources.reservations.cpus, cpus: pruneString(deploy.resources.reservations.cpus),
memory: deploy.resources.reservations.memory memory: pruneString(deploy.resources.reservations.memory)
}) })
}), }),
restart_policy: pruneObject({ restart_policy: pruneObject({
condition: deploy.restartPolicy.condition, condition: pruneString(deploy.restartPolicy.condition),
delay: deploy.restartPolicy.delay, delay: pruneString(deploy.restartPolicy.delay),
// NOTE: Could be a potential bug. // NOTE: Could be a potential bug.
maxAttempts: parseInt(deploy.restartPolicy.maxAttempts) ?? undefined, maxAttempts: pruneNumber(parseInt(deploy.restartPolicy.maxAttempts)),
window: deploy.restartPolicy.window window: pruneString(deploy.restartPolicy.window)
}), }),
labels: pruneObject( labels: pruneObject(
Object.fromEntries(labels.map((label) => [label.key, label.value])) Object.fromEntries(labels.map((label) => [label.key, label.value]))

Loading…
Cancel
Save