Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
tools
tabacco
Commits
c42a6349
Commit
c42a6349
authored
Jun 18, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce source name uniqueness in config
parent
46dcd9ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
config.go
config.go
+8
-1
No files found.
config.go
View file @
c42a6349
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment