func ParseConstraints(s string) (Constraints, error) {
	var cons Constraints

	fields := strings.Split(s, ",")
	fieldsLen := len(fields)
	if fieldsLen < 1 || fieldsLen > 3 {
		return cons, deviceParseErr
	}
	if fieldsLen == 1 {
		cons.Count = 1
		cons.Type = DeviceType(fields[0])
	} else {
		count, err := parseCount(fields[0])
		if err != nil {
			return Constraints{}, err
		}
		cons.Count = count
		cons.Type = DeviceType(fields[1])

		if fieldsLen == 3 {
			attr, err := parseAttributes(fields[2])
			if err != nil {
				return Constraints{}, err
			}
			cons.Attributes = attr
		}
	}
	return cons, nil
}
// ParseConstraints parses the specified string and creates a
// Constraints structure.
//
// The acceptable format for device constraints is a comma separated
// sequence of: COUNT, TYPE, and ATTRIBUTES with format like
//
//    <device-name>=[<count>,]<device-class>|<vendor/type>[,<attributes>]
//
// where
//
//    COUNT is the number of devices that the user has asked for - count min and max are the
//    number of devices the charm requires. If unspecified, COUNT defaults to 1.
ParseConstraints parses the specified string and creates a
Constraints structure.

The acceptable format for device constraints is a comma separated
sequence of: COUNT, TYPE, and ATTRIBUTES with format like





COUNT is the number of devices that the user has asked for - count min and max are the
number of devices the charm requires. If unspecified, COUNT defaults to 1.
// ParseConstraints parses the specified string and creates a // Constraints structure . // // The acceptable format for device constraints is a comma separated // sequence of : COUNT TYPE and ATTRIBUTES with format like // // <device - name > = [ <count > ] <device - class > |<vendor / type > [ <attributes > ] // // where // // COUNT is the number of devices that the user has asked for - count min and max are the // number of devices the charm requires . If unspecified COUNT defaults to 1 .
func ParseConstraints(s string) (Constraints, error) {
	var cons Constraints
	fields := strings.Split(s, ",")
	fieldsLen := len(fields)
	if fieldsLen < 1 || fieldsLen > 3 {
		return cons, deviceParseErr
	}
	if fieldsLen == 1 {
		cons.Count = 1
		cons.Type = DeviceType(fields[0])
	} else {
		count, err := parseCount(fields[0])
		if err != nil {
			return Constraints{}, err
		}
		cons.Count = count
		cons.Type = DeviceType(fields[1])
		if fieldsLen == 3 {
			attr, err := parseAttributes(fields[2])
			if err != nil {
				return Constraints{}, err
			}
			cons.Attributes = attr
		}
	}
	return cons, nil
}
func ParseConstraints ( s string ) ( Constraints , error ) { var cons Constraints fields := strings . Split ( s , " " ) fieldsLen := len ( fields ) if fieldsLen < 1 || fieldsLen > 3 { return cons , deviceParseErr } if fieldsLen == 1 { cons . Count = 1 cons . Type = DeviceType ( fields [ 0 ] ) } else { count , err := parseCount ( fields [ 0 ] ) if err != nil { return Constraints { } , err } cons . Count = count cons . Type = DeviceType ( fields [ 1 ] ) if fieldsLen == 3 { attr , err := parseAttributes ( fields [ 2 ] ) if err != nil { return Constraints { } , err } cons . Attributes = attr } } return cons , nil }
ParseConstraints parses the specified string and creates a
Constraints structure.
ParseConstraints parses the specified string and creates a Constraints structure .