daemon: getInspectData(): reduce cyclomatic complexity
Use an early return if looking up metadata fails. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
313a7d716d
commit
92d2e12a4d
1 changed files with 6 additions and 7 deletions
|
@ -197,17 +197,16 @@ func (daemon *Daemon) getInspectData(container *container.Container) (*types.Con
|
|||
}
|
||||
|
||||
graphDriverData, err := container.RWLayer.Metadata()
|
||||
// If container is marked as Dead, the container's graphdriver metadata
|
||||
// could have been removed, it will cause error if we try to get the metadata,
|
||||
// we can ignore the error if the container is dead.
|
||||
if err != nil {
|
||||
if !container.Dead {
|
||||
if container.Dead {
|
||||
// container is marked as Dead, and its graphDriver metadata may
|
||||
// have been removed; we can ignore errors.
|
||||
return contJSONBase, nil
|
||||
}
|
||||
return nil, errdefs.System(err)
|
||||
}
|
||||
} else {
|
||||
contJSONBase.GraphDriver.Data = graphDriverData
|
||||
}
|
||||
|
||||
contJSONBase.GraphDriver.Data = graphDriverData
|
||||
return contJSONBase, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue