featurens: fix detecting duplicated namespaces problem
This commit is contained in:
parent
f0e21df783
commit
50437f32a1
@ -72,7 +72,7 @@ func RegisterDetector(name string, d Detector) {
|
|||||||
func Detect(files tarutil.FilesMap) ([]database.Namespace, error) {
|
func Detect(files tarutil.FilesMap) ([]database.Namespace, error) {
|
||||||
detectorsM.RLock()
|
detectorsM.RLock()
|
||||||
defer detectorsM.RUnlock()
|
defer detectorsM.RUnlock()
|
||||||
var namespaces []database.Namespace
|
namespaces := map[string]*database.Namespace{}
|
||||||
for name, detector := range detectors {
|
for name, detector := range detectors {
|
||||||
namespace, err := detector.Detect(files)
|
namespace, err := detector.Detect(files)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -82,11 +82,15 @@ func Detect(files tarutil.FilesMap) ([]database.Namespace, error) {
|
|||||||
|
|
||||||
if namespace != nil {
|
if namespace != nil {
|
||||||
log.WithFields(log.Fields{"name": name, "namespace": namespace.Name}).Debug("detected namespace")
|
log.WithFields(log.Fields{"name": name, "namespace": namespace.Name}).Debug("detected namespace")
|
||||||
namespaces = append(namespaces, *namespace)
|
namespaces[namespace.Name] = namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return namespaces, nil
|
nslist := []database.Namespace{}
|
||||||
|
for _, ns := range namespaces {
|
||||||
|
nslist = append(nslist, *ns)
|
||||||
|
}
|
||||||
|
return nslist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiredFilenames returns the total list of files required for all
|
// RequiredFilenames returns the total list of files required for all
|
||||||
|
Loading…
Reference in New Issue
Block a user