diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-02-14 17:52:49 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-02-21 10:51:42 -0500 |
commit | a3dbb7a837f0c6fe9e12aec6da3778759632f7d1 (patch) | |
tree | e532adb39652b5fa3d1263880e2587285ae4614e /libpod/in_memory_state.go | |
parent | 7fdd20ae5a1ced1faceab9cb0a6e553343911a0b (diff) | |
download | podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.tar.gz podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.tar.bz2 podman-a3dbb7a837f0c6fe9e12aec6da3778759632f7d1.zip |
Add ability to rewrite pod configs in the database
Necessary for rewriting lock IDs as part of renumber.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r-- | libpod/in_memory_state.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go index 2f8fafa39..ab4fc8ba7 100644 --- a/libpod/in_memory_state.go +++ b/libpod/in_memory_state.go @@ -410,6 +410,26 @@ func (s *InMemoryState) RewriteContainerConfig(ctr *Container, newCfg *Container return nil } +// RewritePodConfig rewrites a pod's configuration. +// This function is DANGEROUS, even with in-memory state. +// Please read the full comment on it in state.go before using it. +func (s *InMemoryState) RewritePodConfig(pod *Pod, newCfg *PodConfig) error { + if !pod.valid { + return ErrPodRemoved + } + + // If the pod does not exist, return error + statePod, ok := s.pods[pod.ID()] + if !ok { + pod.valid = false + return errors.Wrapf(ErrNoSuchPod, "pod with ID %s not found in state", pod.ID()) + } + + statePod.config = newCfg + + return nil +} + // Volume retrieves a volume from its full name func (s *InMemoryState) Volume(name string) (*Volume, error) { if name == "" { |