fix(frontend): fixed incorrect serializing of `build.placement.constraints` and `build.placement.preferences`

pull/85/head
Samuel Rowe 3 years ago
parent 4a9738c4b3
commit 6a61cb135a

@ -7,7 +7,9 @@ import {
extractObjectOrArray, extractObjectOrArray,
extractArray, extractArray,
pruneString, pruneString,
pruneNumber pruneNumber,
packArrayAsObject,
packArrayAsStrings
} from "../../../utils/forms"; } from "../../../utils/forms";
export const tabs = [ export const tabs = [
@ -428,16 +430,8 @@ export const getFinalValues = (
build: pruneObject({ build: pruneObject({
context: pruneString(build.context), context: pruneString(build.context),
dockerfile: pruneString(build.dockerfile), dockerfile: pruneString(build.dockerfile),
args: pruneObject( args: packArrayAsObject(build.arguments, "key", "value"),
Object.fromEntries( ssh: packArrayAsStrings(build.sshAuthentications, "id", "path", "="),
build.arguments.map((argument) => [argument.key, argument.value])
)
),
ssh: pruneArray(
build.sshAuthentications.map((authentication) =>
[authentication.id, authentication.path].join("=")
)
),
cache_from: pruneArray(build.cacheFrom), cache_from: pruneArray(build.cacheFrom),
cache_to: pruneArray(build.cacheTo), cache_to: pruneArray(build.cacheTo),
extra_hosts: pruneArray( extra_hosts: pruneArray(
@ -460,8 +454,18 @@ export const getFinalValues = (
replicas: pruneString(deploy.replicas), replicas: pruneString(deploy.replicas),
endpoint_mode: pruneString(deploy.endpointMode), endpoint_mode: pruneString(deploy.endpointMode),
placement: pruneObject({ placement: pruneObject({
constraints: pruneArray(deploy.placement.constraints), constraints: packArrayAsStrings(
preferences: pruneArray(deploy.placement.preferences) deploy.placement.constraints,
"key",
"value",
"="
),
preferences: packArrayAsStrings(
deploy.placement.preferences,
"key",
"value",
"="
)
}), }),
resources: pruneObject({ resources: pruneObject({
limits: pruneObject({ limits: pruneObject({
@ -482,11 +486,7 @@ export const getFinalValues = (
maxAttempts: pruneNumber(parseInt(deploy.restartPolicy.maxAttempts)), maxAttempts: pruneNumber(parseInt(deploy.restartPolicy.maxAttempts)),
window: pruneString(deploy.restartPolicy.window) window: pruneString(deploy.restartPolicy.window)
}), }),
labels: pruneObject( labels: packArrayAsObject(deploy.labels, "key", "value")
Object.fromEntries(
deploy.labels.map((label) => [label.key, label.value])
)
)
}), }),
image: `${values.imageName}${ image: `${values.imageName}${
values.imageTag ? `:${values.imageTag}` : "" values.imageTag ? `:${values.imageTag}` : ""

Loading…
Cancel
Save