Skip to content

Commit

Permalink
eebus: fix duplicate template names (evcc-io#16484)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Oct 3, 2024
1 parent 921837c commit 6395307
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
template: eebus
template: elli-2
products:
- brand: Elli
description:
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/ghost.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
template: eebus
template: ghost
products:
- brand: eSystems
description:
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/porsche-wallbox.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
template: eebus
template: porsche-wallbox
products:
- brand: Porsche
description:
Expand Down
4 changes: 4 additions & 0 deletions util/templates/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func load(class Class) (res []Template) {
return fmt.Errorf("processing template '%s' failed: %w", filepath, err)
}

if slices.ContainsFunc(res, func(t Template) bool { return t.Template == tmpl.Template }) {
return fmt.Errorf("duplicate template name '%s' found in file '%s'", tmpl.Template, filepath)
}

res = append(res, tmpl)

return nil
Expand Down

0 comments on commit 6395307

Please sign in to comment.