summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-19 02:49:27 -0400
committerGitHub <noreply@github.com>2020-10-19 02:49:27 -0400
commit7ffcab0854342844a44b2668bd9d98849bf935c8 (patch)
treec7c8b60c8d389314309c7e2e73e3b41f06988fbc /libpod
parent6ec96dc009d73cc2b0a3fa81149ca599b04252e4 (diff)
parent571ae9db7241ffbe1be4f254328cfd2e43369103 (diff)
downloadpodman-7ffcab0854342844a44b2668bd9d98849bf935c8.tar.gz
podman-7ffcab0854342844a44b2668bd9d98849bf935c8.tar.bz2
podman-7ffcab0854342844a44b2668bd9d98849bf935c8.zip
Merge pull request #7908 from rhatdan/diff
fix podman container exists and diff for storage containers
Diffstat (limited to 'libpod')
-rw-r--r--libpod/diff.go20
-rw-r--r--libpod/runtime_cstorage.go4
2 files changed, 16 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
}
diff --git a/libpod/runtime_cstorage.go b/libpod/runtime_cstorage.go
index 03eebeefc..61fdd42d3 100644
--- a/libpod/runtime_cstorage.go
+++ b/libpod/runtime_cstorage.go
@@ -52,6 +52,10 @@ func (r *Runtime) ListStorageContainers() ([]*StorageContainer, error) {
return finalCtrs, nil
}
+func (r *Runtime) StorageContainer(idOrName string) (*storage.Container, error) {
+ return r.store.Container(idOrName)
+}
+
// RemoveStorageContainer removes a container from c/storage.
// The container WILL NOT be removed if it exists in libpod.
// Accepts ID or full name of container.