( modules []Module, )
| 260 | } |
| 261 | |
| 262 | func newModuleSet( |
| 263 | modules []Module, |
| 264 | ) (*moduleSet, error) { |
| 265 | moduleFullNameStringToModule := make(map[string]Module, len(modules)) |
| 266 | opaqueIDToModule := make(map[string]Module, len(modules)) |
| 267 | descriptionToModule := make(map[string]Module, len(modules)) |
| 268 | bucketIDToModule := make(map[string]Module, len(modules)) |
| 269 | commitIDToModule := make(map[uuid.UUID]Module, len(modules)) |
| 270 | for _, module := range modules { |
| 271 | if moduleFullName := module.FullName(); moduleFullName != nil { |
| 272 | moduleFullNameString := moduleFullName.String() |
| 273 | if _, ok := moduleFullNameStringToModule[moduleFullNameString]; ok { |
| 274 | // This should never happen. |
| 275 | return nil, syserror.Newf("duplicate FullName %q when constructing ModuleSet", moduleFullNameString) |
| 276 | } |
| 277 | moduleFullNameStringToModule[moduleFullNameString] = module |
| 278 | } |
| 279 | opaqueID := module.OpaqueID() |
| 280 | if _, ok := opaqueIDToModule[opaqueID]; ok { |
| 281 | // This should never happen. |
| 282 | return nil, syserror.Newf("duplicate OpaqueID %q when constructing ModuleSet", opaqueID) |
| 283 | } |
| 284 | opaqueIDToModule[opaqueID] = module |
| 285 | description := module.Description() |
| 286 | if _, ok := descriptionToModule[description]; ok { |
| 287 | // This should never happen if we construct descriptions appropriately. |
| 288 | return nil, syserror.Newf("duplicate Description %q when constructing ModuleSet", description) |
| 289 | } |
| 290 | descriptionToModule[description] = module |
| 291 | bucketID := module.BucketID() |
| 292 | if bucketID != "" { |
| 293 | if _, ok := bucketIDToModule[bucketID]; ok { |
| 294 | // This should never happen. |
| 295 | return nil, syserror.Newf("duplicate BucketID %q when constructing ModuleSet", bucketID) |
| 296 | } |
| 297 | bucketIDToModule[bucketID] = module |
| 298 | } |
| 299 | commitID := module.CommitID() |
| 300 | if commitID != uuid.Nil { |
| 301 | if _, ok := commitIDToModule[commitID]; ok { |
| 302 | // This should never happen. |
| 303 | return nil, syserror.Newf("duplicate CommitID %q when constructing ModuleSet", uuidutil.ToDashless(commitID)) |
| 304 | } |
| 305 | commitIDToModule[commitID] = module |
| 306 | } |
| 307 | } |
| 308 | moduleSet := &moduleSet{ |
| 309 | modules: modules, |
| 310 | moduleFullNameStringToModule: moduleFullNameStringToModule, |
| 311 | opaqueIDToModule: opaqueIDToModule, |
| 312 | bucketIDToModule: bucketIDToModule, |
| 313 | commitIDToModule: commitIDToModule, |
| 314 | } |
| 315 | for _, module := range modules { |
| 316 | module.setModuleSet(moduleSet) |
| 317 | } |
| 318 | return moduleSet, nil |
| 319 | } |
no test coverage detected
searching dependent graphs…