summaryrefslogtreecommitdiff
path: root/libpod/pod.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-06-05 16:57:58 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-06-11 11:01:13 +0200
commit35ae53067f01c0194dc13513656e57293de95004 (patch)
tree315919e18ad52199b8ec5607d0d41ae9738479eb /libpod/pod.go
parentb4a410215ef0d6ebac6e5b61921f2cbe5d9ac8bd (diff)
downloadpodman-35ae53067f01c0194dc13513656e57293de95004.tar.gz
podman-35ae53067f01c0194dc13513656e57293de95004.tar.bz2
podman-35ae53067f01c0194dc13513656e57293de95004.zip
generate systemd: refactor
Refactor the systemd-unit generation code and move all the logic into `pkg/systemd/generate`. The code was already hard to maintain but I found it impossible to wire the `--new` logic for pods in all the chaos. The code refactoring in this commit will make maintaining the code easier and should make it easier to extend as well. Further changes and refactorings may still be needed but they will easier. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/pod.go')
-rw-r--r--libpod/pod.go14
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)