diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-03 06:56:42 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-15 09:51:15 -0400 |
commit | 22c8270135620bbbeb988076378173e452ec04af (patch) | |
tree | 656db8df0719d224b830acdefdb08019b1b61db6 /libpod/diff.go | |
parent | a1d5a518d3e9db785b7f15e07c679b9ae041ccae (diff) | |
download | podman-22c8270135620bbbeb988076378173e452ec04af.tar.gz podman-22c8270135620bbbeb988076378173e452ec04af.tar.bz2 podman-22c8270135620bbbeb988076378173e452ec04af.zip |
fix podman container exists and diff for storage containers
Current these commands only check if a container exists in libpod. With
this fix, the commands will also check if they are in containers/storage.
This allows users to look at differences within a buildah or CRI-O container.
Currently buildah diff does not exists, so this helps out in that situation
as well as in CRI-O since the cri does not implement a diff command.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/diff.go')
-rw-r--r-- | libpod/diff.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libpod/diff.go b/libpod/diff.go index 5335d701c..43f4d2e96 100644 --- a/libpod/diff.go +++ b/libpod/diff.go @@ -62,18 +62,22 @@ func (r *Runtime) ApplyDiffTarStream(to string, diff io.Reader) error { func (r *Runtime) getLayerID(id string) (string, error) { var toLayer string toImage, err := r.imageRuntime.NewFromLocal(id) + if err == nil { + return toImage.TopLayer(), nil + } + + targetID, err := r.store.Lookup(id) if err != nil { - toCtr, err := r.store.Container(id) + targetID = id + } + toCtr, err := r.store.Container(targetID) + if err != nil { + toLayer, err = layers.FullID(r.store, targetID) if err != nil { - toLayer, err = layers.FullID(r.store, id) - if err != nil { - return "", errors.Errorf("layer, image, or container %s does not exist", id) - } - } else { - toLayer = toCtr.LayerID + return "", errors.Errorf("layer, image, or container %s does not exist", id) } } else { - toLayer = toImage.TopLayer() + toLayer = toCtr.LayerID } return toLayer, nil } |