Skip to content

Commit

Permalink
Add yaml parser workaround for anchors (#907)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Sangmeister <[email protected]>
  • Loading branch information
bastianjoel and jsangmeister authored Apr 19, 2024
1 parent 7b5d0ee commit ba53a47
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ import (
// Unmarshal parses the content of models.yml to a datastruct.q
func Unmarshal(r io.Reader) (map[string]Model, error) {
var m map[string]Model
if err := yaml.NewDecoder(r).Decode(&m); err != nil {

var tmp map[string]interface{}
if err := yaml.NewDecoder(r).Decode(&tmp); err != nil {
return m, err
}

if _, ok := tmp["_meta"]; ok {
delete(tmp, "_meta")
}

cleanYml, err := yaml.Marshal(tmp)
if err != nil {
return m, err
}

if err := yaml.Unmarshal(cleanYml, &m); err != nil {
return nil, fmt.Errorf("decoding models: %w", err)
}
return m, nil
Expand Down

0 comments on commit ba53a47

Please sign in to comment.