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?") } }
func handleDefault(mapContent map[string]interface{}, key string, prop intf.Argument, ciType *metadata.CIType) error { kind := ciType.Prop(key).Kind switch kind { case "MAP_STRING_STRING": mapContent[key] = prop.Map() case "SET_OF_STRING", "LIST_OF_STRING", "SET_OF_CI", "LIST_OF_CI": mapContent[key] = prop.Values() case "BOOLEAN", "INTEGER", "STRING", "ENUM", "CI": mapContent[key] = prop.Value() default: return errors.New("Unexpected value type read from repository; does it exist?") } return nil }