Problem with multiservice task
perrfect opened this issue · 1 comments
perrfect commented
Hello.
I use Levant v0.3.1 and test multiservice task via var-file.
My var-file for multiservice task looks like:
"tasks": [
{
"first_task_name": {
"config": {
"image": "test"
},
"resources": {
"cpu": 100,
"memory": 256
}
},
"second_task_name": {
"config": {
"image": "test"
},
"resources": {
"cpu": 100,
"memory": 256
}
}
}
]
job.nomad looks like:
task "[[ .job.tasks ]]" {
driver = "docker"
resources {
cpu = [[ .job.tasks.resources.cpu ]]
memory = [[ .job.tasks.resources.memory ]]
}
And I run my job.nomad file:
levant plan -log-level=debug -var-file=vars.json -address='${env.NOMAD_URL}' job.nomad
But getting the error:
[ERROR] levant/command: template: jobTemplate:113:21: executing "jobTemplate" at <.job.tasks.resources.cpu>: can't evaluate field resources in type interface {}
I don't understand where is a mistake and why json doesn't parse correctly.
Please help me.
Thank you.
hiddewie commented
.job.tasks
is an array, so you cannot call a field on an array.
You can loop over the array with range .job.tasks
and then use .resources.cpu
within the range.