summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-06-28 21:17:13 +0200
committerMatej Vasek <mvasek@redhat.com>2021-07-01 12:01:46 +0200
commit86c6014145d5b8d4ea51f338beb9bddaa8b5a334 (patch)
tree056769253cf35f00bdd46389bddd9c076c31a00e /cmd/podman
parentfd1715568b7c14451dcf2581c385c8d3e307d30e (diff)
downloadpodman-86c6014145d5b8d4ea51f338beb9bddaa8b5a334.tar.gz
podman-86c6014145d5b8d4ea51f338beb9bddaa8b5a334.tar.bz2
podman-86c6014145d5b8d4ea51f338beb9bddaa8b5a334.zip
Implement --archive flag for podman cp
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/cp.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index 0ad258824..c1f1e27f5 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -28,13 +28,13 @@ var (
You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. If "-" is specified for either the SRC_PATH or DEST_PATH, you can also stream a tar archive from STDIN or to STDOUT. The CONTAINER can be a running or stopped container. The SRC_PATH or DEST_PATH can be a file or a directory.
`
cpCommand = &cobra.Command{
- Use: "cp [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
+ Use: "cp [options] [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
Short: "Copy files/folders between a container and the local filesystem",
Long: cpDescription,
Args: cobra.ExactArgs(2),
RunE: cp,
ValidArgsFunction: common.AutocompleteCpCommand,
- Example: "podman cp [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
+ Example: "podman cp [options] [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
}
containerCpCommand = &cobra.Command{
@@ -50,12 +50,14 @@ var (
var (
cpOpts entities.ContainerCpOptions
+ chown bool
)
func cpFlags(cmd *cobra.Command) {
flags := cmd.Flags()
flags.BoolVar(&cpOpts.Extract, "extract", false, "Deprecated...")
flags.BoolVar(&cpOpts.Pause, "pause", true, "Deprecated")
+ flags.BoolVarP(&chown, "archive", "a", true, `Chown copied files to the primary uid/gid of the destination container.`)
_ = flags.MarkHidden("extract")
_ = flags.MarkHidden("pause")
}
@@ -378,7 +380,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er
target = filepath.Dir(target)
}
- copyFunc, err := registry.ContainerEngine().ContainerCopyFromArchive(registry.GetContext(), container, target, reader)
+ copyFunc, err := registry.ContainerEngine().ContainerCopyFromArchive(registry.GetContext(), container, target, reader, entities.CopyOptions{Chown: chown})
if err != nil {
return err
}