Fronius Gen24: fix integer deprecated (#4602)
This commit is contained in:
parent
2252758bd9
commit
f06922b298
4 changed files with 15 additions and 3 deletions
|
|
@ -14,6 +14,8 @@ params:
|
|||
- name: host
|
||||
- name: port
|
||||
default: 502
|
||||
- name: integer
|
||||
deprecated: true
|
||||
render: |
|
||||
# reference: https://github.com/volkszaehler/mbmd/blob/master/meters/sunspec/models.go
|
||||
{{- if eq .usage "grid" }}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path"
|
||||
|
|
@ -28,8 +29,12 @@ func init() {
|
|||
}
|
||||
|
||||
func FromBytes(b []byte) (Template, error) {
|
||||
// panic if template definition contains unknown fields
|
||||
dec := yaml.NewDecoder(bytes.NewReader(b))
|
||||
dec.KnownFields(true)
|
||||
|
||||
var definition TemplateDefinition
|
||||
if err := yaml.Unmarshal(b, &definition); err != nil {
|
||||
if err := dec.Decode(&definition); err != nil {
|
||||
return Template{}, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
|
@ -37,7 +38,9 @@ func RenderInstance(class Class, other map[string]interface{}) (Instance, error)
|
|||
}
|
||||
|
||||
var instance Instance
|
||||
err = yaml.Unmarshal(b, &instance)
|
||||
if err = yaml.Unmarshal(b, &instance); err == nil && instance.Type == "" {
|
||||
err = errors.New("empty instance type- check for missing usage")
|
||||
}
|
||||
|
||||
return instance, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,9 +317,11 @@ func (t *Template) RenderResult(renderMode string, other map[string]interface{})
|
|||
out := strings.ToLower(key)
|
||||
|
||||
if i, p := t.ParamByName(key); i == -1 {
|
||||
if !slices.Contains(predefinedTemplateProperties, strings.ToLower(key)) {
|
||||
if !slices.Contains(predefinedTemplateProperties, out) {
|
||||
return nil, values, fmt.Errorf("invalid key: %s", key)
|
||||
}
|
||||
} else if p.Deprecated {
|
||||
continue
|
||||
} else {
|
||||
out = p.Name
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue