Esempio n. 1
0
func (al *appsVolume) Set(s string) error {
	vol, err := types.VolumeFromString(s)
	if err != nil {
		return errwrap.Wrap(fmt.Errorf("invalid value in --volume flag %q", s), err)
	}

	(*apps.Apps)(al).Volumes = append((*apps.Apps)(al).Volumes, *vol)
	return nil
}
Esempio n. 2
0
func (vfl *VolumesFlag) Set(val string) error {
	if !strings.ContainsRune(val, ',') {
		if pieces := strings.SplitN(val, ":", 2); len(pieces) == 1 {
			val += ",kind=empty"
		} else {
			val = fmt.Sprintf("%v,kind=host,source=%v", pieces[0], url.QueryEscape(pieces[1]))
		}
	}
	if val[0] == '-' {
		val = val[1:] + ",readOnly=true"
	}

	if v, err := types.VolumeFromString(val); err != nil {
		return err
	} else {
		// TODO: check for duplicates?
		*vfl = append(*vfl, *v)
		return nil
	}
}