Commit c42a6349 authored by ale's avatar ale

Enforce source name uniqueness in config

parent 46dcd9ea
......@@ -96,13 +96,20 @@ func (c *Config) parse() (*runtimeAssets, error) {
// Validate the sources (Parse is called later at runtime).
// Sources that fail the check are removed from the
// SourceSpecs array.
// SourceSpecs array. We also check that sources have unique
// names.
tmp := make(map[string]struct{}{})
var srcs []*SourceSpec
for _, spec := range c.SourceSpecs {
if err := spec.Check(handlerMap); err != nil {
merr.Add(fmt.Errorf("source %s: %v", spec.Name, err))
continue
}
if _, ok := tmp[spec.Name]; ok {
merr.Add(fmt.Errorf("duplicated source %s", spec.Name))
continue
}
tmp[spec.Name] = struct{}{}
srcs = append(srcs, spec)
}
c.SourceSpecs = srcs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment