Beispiel #1
0
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
}