diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2021-01-22 15:38:51 +0100 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2021-01-29 15:23:56 -0500 |
commit | 0b500515d8b8900851763a17b61609556f58d99c (patch) | |
tree | c64ac070ff3c9bdfba07bbf3e12a1126f6633fe6 /pkg/domain/infra/abi/archive.go | |
parent | 2393dd304de3453fabfb7eac99ef6b2fb308bd29 (diff) | |
download | podman-0b500515d8b8900851763a17b61609556f58d99c.tar.gz podman-0b500515d8b8900851763a17b61609556f58d99c.tar.bz2 podman-0b500515d8b8900851763a17b61609556f58d99c.zip |
libpod: add (*Container).ResolvePath()
Add an API to libpod to resolve a path on the container. We can
refactor the code that was originally written for copy. Other
functions are requiring a proper path resolution, so libpod seems
like a reasonable home for sharing that code.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/archive.go')
-rw-r--r-- | pkg/domain/infra/abi/archive.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pkg/domain/infra/abi/archive.go b/pkg/domain/infra/abi/archive.go index 809813756..c64dfb02a 100644 --- a/pkg/domain/infra/abi/archive.go +++ b/pkg/domain/infra/abi/archive.go @@ -26,13 +26,18 @@ func (ic *ContainerEngine) ContainerCopyFromArchive(ctx context.Context, nameOrI return nil, err } + containerMountPoint, err := container.Mount() + if err != nil { + return nil, err + } + unmount := func() { if err := container.Unmount(false); err != nil { logrus.Errorf("Error unmounting container: %v", err) } } - _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerPath) + _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath) if err != nil { unmount() return nil, err @@ -71,6 +76,11 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID return nil, err } + containerMountPoint, err := container.Mount() + if err != nil { + return nil, err + } + unmount := func() { if err := container.Unmount(false); err != nil { logrus.Errorf("Error unmounting container: %v", err) @@ -83,7 +93,7 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID containerPath = "/." } - _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerPath) + _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath) if err != nil { unmount() return nil, err |