Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yaml parser workaround for anchors #907

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading