summaryrefslogtreecommitdiff
path: root/cmd/podman/create_cli.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-06-11 15:27:42 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-09 19:30:03 +0000
commit4855998f1cf533b27e48b2ded5541841fe6a3ea6 (patch)
tree7bb7e276e04f7d235e667bf088e5c87e43a74924 /cmd/podman/create_cli.go
parentc7424b69911222c2dc92a41308685f1e6d36fb53 (diff)
downloadpodman-4855998f1cf533b27e48b2ded5541841fe6a3ea6.tar.gz
podman-4855998f1cf533b27e48b2ded5541841fe6a3ea6.tar.bz2
podman-4855998f1cf533b27e48b2ded5541841fe6a3ea6.zip
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 <umohnani@redhat.com> Closes: #931 Approved by: mheon
Diffstat (limited to 'cmd/podman/create_cli.go')
-rw-r--r--cmd/podman/create_cli.go24
1 files changed, 18 insertions, 6 deletions
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)
}