func (am *appMountVolume) Set(s string) error { pairs, err := url.ParseQuery(strings.Replace(s, ",", "&", -1)) if err != nil { return err } mount := schema.Mount{} target, ok := pairs["target"] if !ok { return fmt.Errorf("missing target= parameter") } if len(target) != 1 { return fmt.Errorf("label %s with multiple values %q", "target", target) } mount.Path = target[0] delete(pairs, "target") vol, err := types.VolumeFromParams(pairs) if err != nil { return errwrap.Wrap(fmt.Errorf("error parsing volume component of MountVolume"), err) } mount.AppVolume = vol mount.Volume = vol.Name as := (*apps.Apps)(am) if as.Count() == 0 { return fmt.Errorf("an image is required before any MountVolumes") } app := as.Last() app.Mounts = append(app.Mounts, mount) return nil }
func (mf *MountsFlag) Set(val string) error { mnt := schema.Mount{} pieces := strings.SplitN(val, ":", 2) if name, err := types.NewACName(pieces[0]); err != nil { return err } else { mnt.Volume = *name } if len(pieces) == 1 { mnt.Path = mnt.Volume.String() } else { mnt.Path = pieces[1] } *mf = append(*mf, mnt) return nil }
func (al *appMount) Set(s string) error { mount := schema.Mount{} // this is intentionally made similar to types.VolumeFromString() // TODO(iaguis) use MakeQueryString() when appc/spec#520 is merged m, err := url.ParseQuery(strings.Replace(s, ",", "&", -1)) if err != nil { return err } for key, val := range m { if len(val) > 1 { return fmt.Errorf("label %s with multiple values %q", key, val) } switch key { case "volume": mv, err := types.NewACName(val[0]) if err != nil { return errwrap.Wrap(fmt.Errorf("invalid volume name %q in --mount flag %q", val[0], s), err) } mount.Volume = *mv case "target": mount.Path = val[0] default: return fmt.Errorf("unknown mount parameter %q", key) } } as := (*apps.Apps)(al) if as.Count() == 0 { as.Mounts = append(as.Mounts, mount) } else { app := as.Last() app.Mounts = append(app.Mounts, mount) } return nil }