Remove dependency from config repo (#2182)
The templates infrastructure replaces this
This commit is contained in:
parent
3b7f3824a5
commit
fb1d6f552f
10 changed files with 64 additions and 179 deletions
|
|
@ -1,35 +0,0 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"github.com/evcc-io/config/registry"
|
||||
_ "github.com/evcc-io/config/templates" // import all config templates
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// ConfigTemplate is a configuration template from https://github.com/evcc-io/config
|
||||
type ConfigTemplate struct {
|
||||
registry.Template
|
||||
Config map[string]interface{}
|
||||
}
|
||||
|
||||
// ConfigTemplates returns configuration templates for giving class
|
||||
func ConfigTemplates(class string) (res []ConfigTemplate) {
|
||||
templates := registry.TemplatesByClass(class)
|
||||
|
||||
for _, tmpl := range templates {
|
||||
var conf map[string]interface{}
|
||||
if err := yaml.Unmarshal([]byte(tmpl.Sample), &conf); err != nil {
|
||||
// silently ignore errors here
|
||||
continue
|
||||
}
|
||||
|
||||
parsed := ConfigTemplate{
|
||||
Template: tmpl,
|
||||
Config: conf,
|
||||
}
|
||||
|
||||
res = append(res, parsed)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue