summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-05-14 19:30:11 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-17 23:10:12 +0000
commit018d2c6b1d23acf7fe67e809498bc354eaf6becf (patch)
tree7e4a605898905c0e0b259717d642ecbabf2516d3 /libpod/in_memory_state.go
parentc45d4c6d5ce83a89f4c536e529c2a6e7a770837e (diff)
downloadpodman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.tar.gz
podman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.tar.bz2
podman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.zip
Add pod state
Add a mutable state to pods, and database backend sutable for modifying and updating said state. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #784 Approved by: rhatdan
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 386ace5b6..36077b9d1 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -604,6 +604,36 @@ func (s *InMemoryState) RemoveContainerFromPod(pod *Pod, ctr *Container) error {
return nil
}
+// UpdatePod updates a pod in the state
+// This is a no-op as there is no backing store
+func (s *InMemoryState) UpdatePod(pod *Pod) error {
+ if !pod.valid {
+ return ErrPodRemoved
+ }
+
+ if _, ok := s.pods[pod.ID()]; !ok {
+ pod.valid = false
+ return errors.Wrapf(ErrNoSuchPod, "no pod exists in state with ID %s", pod.ID())
+ }
+
+ return nil
+}
+
+// SavePod updates a pod in the state
+// This is a no-op at there is no backing store
+func (s *InMemoryState) SavePod(pod *Pod) error {
+ if !pod.valid {
+ return ErrPodRemoved
+ }
+
+ if _, ok := s.pods[pod.ID()]; !ok {
+ pod.valid = false
+ return errors.Wrapf(ErrNoSuchPod, "no pod exists in state with ID %s", pod.ID())
+ }
+
+ return nil
+}
+
// AllPods retrieves all pods currently in the state
func (s *InMemoryState) AllPods() ([]*Pod, error) {
pods := make([]*Pod, 0, len(s.pods))