buildAmbiguousResult constructs a resolvedDatabase with multiple candidates.
(matches []databaseEntry)
| 164 | |
| 165 | // buildAmbiguousResult constructs a resolvedDatabase with multiple candidates. |
| 166 | func buildAmbiguousResult(matches []databaseEntry) *resolvedDatabase { |
| 167 | candidates := make([]Candidate, 0, len(matches)) |
| 168 | dsIDs := make(map[string]string, len(matches)) |
| 169 | engines := make(map[string]string, len(matches)) |
| 170 | projects := make(map[string]string, len(matches)) |
| 171 | for _, db := range matches { |
| 172 | candidates = append(candidates, Candidate{ |
| 173 | Database: db.Name, |
| 174 | Instance: extractShortName(db.InstanceResource.Name), |
| 175 | Project: extractShortName(db.Project), |
| 176 | Engine: db.InstanceResource.Engine, |
| 177 | }) |
| 178 | dsIDs[db.Name] = selectDataSource(db.InstanceResource.DataSources) |
| 179 | engines[db.Name] = db.InstanceResource.Engine |
| 180 | projects[db.Name] = db.Project |
| 181 | } |
| 182 | return &resolvedDatabase{ |
| 183 | ambiguous: true, |
| 184 | candidates: candidates, |
| 185 | dataSourceIDs: dsIDs, |
| 186 | engines: engines, |
| 187 | projects: projects, |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // resolveDatabase resolves a database name to a unique resource using tiered matching. |
| 192 | func (s *Server) resolveDatabase(ctx context.Context, database, instance, project string) (*resolvedDatabase, error) { |
no test coverage detected