-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I get this error when there is empty items in array:
json: cannot unmarshal array into Go value of type swarm.Resources
I'm trying to update service image. for that I have to first inspect current Service and then pull the whole Spec section then make my changed and then call the service update.
let say the JSON object is like:
`
{
"Name":"myservice",
"Labels":{
"com.df.distribute":"true",
"com.df.notify":"true",
"com.df.port":"80",
"com.df.serviceDomain":"my.domain.com",
"com.df.servicePath":"/"
},
"TaskTemplate":{
"ContainerSpec":{
"Image":"my/image:2.1.1"
},
"Resources":{
"Limits":{
},
"Reservations":{
}
},
"RestartPolicy":{
"Condition":"any",
"MaxAttempts":0
},
"Placement":{
"Constraints":[
"node.role==worker"
]
},
"Networks":[
{
"Target":"47ov8tcgvmuie3qhde3xfpb2y"
},
{
"Target":"4naryq4iva5unmq1u5ye2z2tj"
}
]
},
"Mode":{
"Replicated":{
"Replicas":2
}
},
"UpdateConfig":{
"Parallelism":1,
"FailureAction":"pause"
},
"Networks":[
{
"Target":"proxy"
},
{
"Target":"mynet"
}
],
"EndpointSpec":{
"Mode":"vip"
}
}
`
as you see in the JSON the Resource has empty arrays and if I take them off the API will works fine.
the point is using Curl command it works with no error and i dont need to remove emty items.
quick work around for this is that I have to process the array and remove all empty elements.
seems this is like GO error
Docker Version:
`
Client:
Version: 1.12.3-cs3
API version: 1.24
Go version: go1.6.3
Git commit: 781bb16
Built:
OS/Arch: linux/amd64
Server:
Version: 1.12.3-cs3
API version: 1.24
Go version: go1.6.3
Git commit: 781bb16
Built:
OS/Arch: linux/amd64
`