mirror of https://github.com/docker/cli.git
docker service inspect fails when TaskTemplate.Resources is nil
When doing `docker service inspect --pretty` on services without
`TaskTemplate.Resources` or `TaskTemplate.Resources.Limits`, the command
fails. This is due to a missing check on ResourceLimitPids().
This bug has been introduced by 395a6d560d
and produces following error message:
```
Template parsing error: template: :139:10: executing "" at <.ResourceLimitPids>: error calling ResourceLimitPids: runtime error: invalid memory address or nil pointer dereference
```
Signed-off-by: Albin Kerouanton <albin@akerouanton.name>
This commit is contained in:
parent
12b74cb5a0
commit
21da11c5fd
|
@ -502,6 +502,9 @@ func (ctx *serviceInspectContext) ResourceLimitMemory() string {
|
|||
}
|
||||
|
||||
func (ctx *serviceInspectContext) ResourceLimitPids() int64 {
|
||||
if ctx.Service.Spec.TaskTemplate.Resources == nil || ctx.Service.Spec.TaskTemplate.Resources.Limits == nil {
|
||||
return 0
|
||||
}
|
||||
return ctx.Service.Spec.TaskTemplate.Resources.Limits.Pids
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue