From 4855998f1cf533b27e48b2ded5541841fe6a3ea6 Mon Sep 17 00:00:00 2001 From: umohnani8 Date: Mon, 11 Jun 2018 15:27:42 -0400 Subject: Add --volumes-from flag to podman run and create podman now supports --volumes-from flag, which allows users to add all the volumes an existing container has to a new one. Signed-off-by: umohnani8 Closes: #931 Approved by: mheon --- cmd/podman/create_cli.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'cmd/podman/create_cli.go') diff --git a/cmd/podman/create_cli.go b/cmd/podman/create_cli.go index 8ae4b6c64..d0ad28595 100644 --- a/cmd/podman/create_cli.go +++ b/cmd/podman/create_cli.go @@ -75,9 +75,6 @@ func addWarning(warnings []string, msg string) []string { } func parseVolumes(volumes []string) error { - if len(volumes) == 0 { - return nil - } for _, volume := range volumes { arr := strings.SplitN(volume, ":", 3) if len(arr) < 2 { @@ -98,6 +95,21 @@ func parseVolumes(volumes []string) error { return nil } +func parseVolumesFrom(volumesFrom []string) error { + for _, vol := range volumesFrom { + arr := strings.SplitN(vol, ":", 2) + if len(arr) == 2 { + if strings.Contains(arr[1], "Z") || strings.Contains(arr[1], "private") || strings.Contains(arr[1], "slave") || strings.Contains(arr[1], "shared") { + return errors.Errorf("invalid options %q, can only specify 'ro', 'rw', and 'z", arr[1]) + } + if err := validateVolumeOpts(arr[1]); err != nil { + return err + } + } + } + return nil +} + func validateVolumeHostDir(hostDir string) error { if !filepath.IsAbs(hostDir) { return errors.Errorf("invalid host path, must be an absolute path %q", hostDir) @@ -121,20 +133,20 @@ func validateVolumeOpts(option string) error { for _, opt := range options { switch opt { case "rw", "ro": + foundRWRO++ if foundRWRO > 1 { return errors.Errorf("invalid options %q, can only specify 1 'rw' or 'ro' option", option) } - foundRWRO++ case "z", "Z": + foundLabelChange++ if foundLabelChange > 1 { return errors.Errorf("invalid options %q, can only specify 1 'z' or 'Z' option", option) } - foundLabelChange++ case "private", "rprivate", "shared", "rshared", "slave", "rslave": + foundRootPropagation++ if foundRootPropagation > 1 { return errors.Errorf("invalid options %q, can only specify 1 '[r]shared', '[r]private' or '[r]slave' option", option) } - foundRootPropagation++ default: return errors.Errorf("invalid option type %q", option) } -- cgit v1.2.3-54-g00ecf