matchSubstring returns databases whose short name contains the input as a substring.
(databases []databaseEntry, name string)
| 279 | |
| 280 | // matchSubstring returns databases whose short name contains the input as a substring. |
| 281 | func matchSubstring(databases []databaseEntry, name string) []databaseEntry { |
| 282 | var result []databaseEntry |
| 283 | lower := strings.ToLower(name) |
| 284 | for _, db := range databases { |
| 285 | if strings.Contains(strings.ToLower(extractDatabaseName(db.Name)), lower) { |
| 286 | result = append(result, db) |
| 287 | } |
| 288 | } |
| 289 | return result |
| 290 | } |
| 291 | |
| 292 | // extractDatabaseName extracts the database name from a resource name like "instances/prod-pg/databases/employee_db". |
| 293 | func extractDatabaseName(resourceName string) string { |
no test coverage detected