func insertDescriptorValuesIntoMap()

in xray/aws.go [407:442]


func insertDescriptorValuesIntoMap(key string, data interface{}, descriptorMap map[string]interface{}, valueMap map[string]interface{}) {
	descriptorType := descriptorType(descriptorMap)
	if descriptorType == "map" {
		var keySlice []interface{}
		m := keyValue(data, key)
		val := reflect.ValueOf(m)
		if val.Kind() == reflect.Map {
			for _, key := range val.MapKeys() {
				keySlice = append(keySlice, key.Interface())
			}
		}
		if descriptorMap["rename_to"] != nil {
			valueMap[descriptorMap["rename_to"].(string)] = keySlice
		} else {
			valueMap[strings.ToLower(key)] = keySlice
		}
	} else if descriptorType == "list" {
		var count int
		l := keyValue(data, key)
		val := reflect.ValueOf(l)
		count = val.Len()

		if descriptorMap["rename_to"] != nil {
			valueMap[descriptorMap["rename_to"].(string)] = count
		} else {
			valueMap[strings.ToLower(key)] = count
		}
	} else if descriptorType == "value" {
		val := keyValue(data, key)
		if descriptorMap["rename_to"] != nil {
			valueMap[descriptorMap["rename_to"].(string)] = val
		} else {
			valueMap[strings.ToLower(key)] = val
		}
	}
}