From 6395307a538d9fcdce09ef444e0e31b4d9122ec0 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Thu, 3 Oct 2024 18:46:47 +0200 Subject: [PATCH] eebus: fix duplicate template names (#16484) --- .../definition/charger/{elli-wallbox-2.yaml => elli-2.yaml} | 2 +- templates/definition/charger/ghost.yaml | 2 +- templates/definition/charger/porsche-wallbox.yaml | 2 +- util/templates/init.go | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) rename templates/definition/charger/{elli-wallbox-2.yaml => elli-2.yaml} (98%) diff --git a/templates/definition/charger/elli-wallbox-2.yaml b/templates/definition/charger/elli-2.yaml similarity index 98% rename from templates/definition/charger/elli-wallbox-2.yaml rename to templates/definition/charger/elli-2.yaml index f7d882868..5c1149ba1 100644 --- a/templates/definition/charger/elli-wallbox-2.yaml +++ b/templates/definition/charger/elli-2.yaml @@ -1,4 +1,4 @@ -template: eebus +template: elli-2 products: - brand: Elli description: diff --git a/templates/definition/charger/ghost.yaml b/templates/definition/charger/ghost.yaml index 402f4bd98..856585093 100644 --- a/templates/definition/charger/ghost.yaml +++ b/templates/definition/charger/ghost.yaml @@ -1,4 +1,4 @@ -template: eebus +template: ghost products: - brand: eSystems description: diff --git a/templates/definition/charger/porsche-wallbox.yaml b/templates/definition/charger/porsche-wallbox.yaml index 6fa00ae2a..1c24d16e0 100644 --- a/templates/definition/charger/porsche-wallbox.yaml +++ b/templates/definition/charger/porsche-wallbox.yaml @@ -1,4 +1,4 @@ -template: eebus +template: porsche-wallbox products: - brand: Porsche description: diff --git a/util/templates/init.go b/util/templates/init.go index 143c6c614..d34675835 100644 --- a/util/templates/init.go +++ b/util/templates/init.go @@ -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