func ensureUnambiguousFormat(raw map[interface{}]interface{}) error {
	format := FormatUnknown
	matched := []string(nil)
	mismatched := []string(nil)
	keys := []string(nil)
	for k, _ := range raw {
		key, ok := k.(string)
		if !ok {
			// Non-string keys will be an error handled by the schema lib.
			continue
		}
		keys = append(keys, key)
	}
	sort.Strings(keys)
	for _, key := range keys {
		detected := FormatUnknown
		switch key {
		case "containers", "assumes":
			detected = FormatV2
		case "series", "deployment", "min-juju-version":
			detected = FormatV1
		}
		if detected == FormatUnknown {
			continue
		}
		if format == FormatUnknown {
			format = detected
		}
		if format == detected {
			matched = append(matched, key)
		} else {
			mismatched = append(mismatched, key)
		}
	}
	if mismatched != nil {
		return errors.Errorf("ambiguous metadata: keys %s cannot be used with %s",
			`"`+strings.Join(mismatched, `", "`)+`"`,
			`"`+strings.Join(matched, `", "`)+`"`)
	}
	return nil
}
// ensureUnambiguousFormat returns an error if the raw data contains
// both metadata v1 and v2 contents. However is it unable to definitively
// determine which format the charm is as metadata does not contain bases.
ensureUnambiguousFormat returns an error if the raw data contains
both metadata v1 and v2 contents. However is it unable to definitively
determine which format the charm is as metadata does not contain bases.
// ensureUnambiguousFormat returns an error if the raw data contains // both metadata v1 and v2 contents . However is it unable to definitively // determine which format the charm is as metadata does not contain bases .
func ensureUnambiguousFormat(raw map[interface{}]interface{}) error {
	format := FormatUnknown
	matched := []string(nil)
	mismatched := []string(nil)
	keys := []string(nil)
	for k, _ := range raw {
		key, ok := k.(string)
		if !ok {
			continue
		}
		keys = append(keys, key)
	}
	sort.Strings(keys)
	for _, key := range keys {
		detected := FormatUnknown
		switch key {
		case "containers", "assumes":
			detected = FormatV2
		case "series", "deployment", "min-juju-version":
			detected = FormatV1
		}
		if detected == FormatUnknown {
			continue
		}
		if format == FormatUnknown {
			format = detected
		}
		if format == detected {
			matched = append(matched, key)
		} else {
			mismatched = append(mismatched, key)
		}
	}
	if mismatched != nil {
		return errors.Errorf("ambiguous metadata: keys %s cannot be used with %s",
			`"`+strings.Join(mismatched, `", "`)+`"`,
			`"`+strings.Join(matched, `", "`)+`"`)
	}
	return nil
}
func ensureUnambiguousFormat ( raw map [ interface { } ] interface { } ) error { format := FormatUnknown matched := [ ] string ( nil ) mismatched := [ ] string ( nil ) keys := [ ] string ( nil ) for k , _ := range raw { key , ok := k . ( string ) if ! ok { continue } keys = append ( keys , key ) } sort . Strings ( keys ) for _ , key := range keys { detected := FormatUnknown switch key { case " " , " " : detected = FormatV2 case " " , " " , " " : detected = FormatV1 } if detected == FormatUnknown { continue } if format == FormatUnknown { format = detected } if format == detected { matched = append ( matched , key ) } else { mismatched = append ( mismatched , key ) } } if mismatched != nil { return errors . Errorf ( " " , `"` + strings . Join ( mismatched , `", "` ) + `"` , `"` + strings . Join ( matched , `", "` ) + `"` ) } return nil }
ensureUnambiguousFormat returns an error if the raw data contains
both metadata v1 and v2 contents.
ensureUnambiguousFormat returns an error if the raw data contains both metadata v1 and v2 contents .
// Non-string keys will be an error handled by the schema lib.