Ejemplo n.º 1
0
func translateProp(ciType *metadata.CIType, prop intf.Argument) (result interface{}, err error) {
	key := prop.Name()
	kind := ciType.Prop(key).Kind

	if kind == "" {
		return "error", errors.New("Unknown property type " + ciType.Type + "->" + key)
	}

	switch kind {

	case "BOOLEAN", "INTEGER", "STRING", "ENUM":
		return prop.Value(), nil

	case "CI":
		return mapRef(prop.Value()), nil

	case "MAP_STRING_STRING":
		return mapStringString(prop.Map()), nil

	case "SET_OF_STRING", "LIST_OF_STRING":
		return mapSetOfStrings(prop.Values()), nil

	case "SET_OF_CI", "LIST_OF_CI":
		return mapSetOfCis(prop.Values()), nil

	default:
		return "error", errors.New("Unknown property kind " + kind + " --> XLD server newer than client?")

	}
}