validateScopeCollFromMappings performs the $scope.$collection validations in the type mappings defined. It also performs - single scope validation across collections - verify scope to collection mapping with kv manifest
(bucket string, im *mapping.IndexMappingImpl, ignoreCollNotFoundErrs bool)
| 218 | // - single scope validation across collections |
| 219 | // - verify scope to collection mapping with kv manifest |
| 220 | func validateScopeCollFromMappings(bucket string, |
| 221 | im *mapping.IndexMappingImpl, ignoreCollNotFoundErrs bool) (*Scope, error) { |
| 222 | sName, collNames, typeMappings, err := getScopeCollTypeMappings(im, false) |
| 223 | if err != nil { |
| 224 | return nil, err |
| 225 | } |
| 226 | |
| 227 | manifest, err := GetBucketManifest(bucket) |
| 228 | if err != nil { |
| 229 | return nil, err |
| 230 | } |
| 231 | |
| 232 | rv := &Scope{Collections: make([]Collection, 0, len(collNames))} |
| 233 | for _, scope := range manifest.Scopes { |
| 234 | if scope.Name == sName { |
| 235 | rv.Name = scope.Name |
| 236 | rv.Uid = scope.Uid |
| 237 | OUTER: |
| 238 | for i := range collNames { |
| 239 | for _, collection := range scope.Collections { |
| 240 | if collection.Name == collNames[i] { |
| 241 | rv.Collections = append(rv.Collections, Collection{ |
| 242 | Uid: collection.Uid, |
| 243 | Name: collection.Name, |
| 244 | typeMapping: typeMappings[i], |
| 245 | }) |
| 246 | continue OUTER |
| 247 | } |
| 248 | } |
| 249 | if !ignoreCollNotFoundErrs { |
| 250 | return nil, fmt.Errorf("collection_utils: collection:"+ |
| 251 | " '%s' doesn't belong to scope: '%s' in bucket: '%s'", |
| 252 | collNames[i], sName, bucket) |
| 253 | } |
| 254 | } |
| 255 | break |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | if rv.Name == "" { |
| 260 | return nil, fmt.Errorf("collection_utils: scope:"+ |
| 261 | " '%s' not found in bucket: '%s' ", |
| 262 | sName, bucket) |
| 263 | } |
| 264 | |
| 265 | return rv, nil |
| 266 | } |
| 267 | |
| 268 | func enhanceMappingsWithCollMetaField(tm map[string]*mapping.DocumentMapping) error { |
| 269 | OUTER: |
no test coverage detected