diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/pod.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/pod.go b/libpod/pod.go index db87e60f2..f53290876 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -257,6 +257,20 @@ func (p *Pod) InfraContainerID() (string, error) { return p.state.InfraContainerID, nil } +// InfraContainer returns the infra container. +func (p *Pod) InfraContainer() (*Container, error) { + if !p.HasInfraContainer() { + return nil, errors.New("pod has no infra container") + } + + id, err := p.InfraContainerID() + if err != nil { + return nil, err + } + + return p.runtime.state.Container(id) +} + // TODO add pod batching // Lock pod to avoid lock contention // Store and lock all containers (no RemoveContainer in batch guarantees cache will not become stale) |