Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed May 18, 2024
1 parent 5f9df45 commit 149ec44
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/controller/generate/output/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,33 @@ func updateASTFile(body ast.Node, pkgs []*aqua.Package) error {
return fmt.Errorf(`find a mapping value node "packages": %w`, err)
}

if values == nil {
values, err := wast.NormalizeMappingValueNodes(body)
if err != nil {
return err

Check failure on line 76 in pkg/controller/generate/output/insert.go

View workflow job for this annotation

GitHub Actions / test / test

error returned from external package is unwrapped: sig: func github.com/aquaproj/aqua/v2/pkg/ast.NormalizeMappingValueNodes(node github.com/goccy/go-yaml/ast.Node) ([]*github.com/goccy/go-yaml/ast.MappingValueNode, error) (wrapcheck)
}
idx := len(values)
mn, ok := node.(*ast.MappingValueNode)
if !ok {
return errors.New("body must be a mapping value node")
}
mv, ok := body.(*ast.MappingNode)
if !ok {
return errors.New("body must be a mapping node")
}
latterValues := make([]*ast.MappingValueNode, len(mv.Values[idx:]))
copy(latterValues, mv.Values[idx:])
mv.Values = mv.Values[:idx]
mv.Merge(&ast.MappingNode{
Values: []*ast.MappingValueNode{
mn,
},
})
mv.Merge(&ast.MappingNode{
Values: latterValues,
})
return nil
}

return appendPkgsNode(values, node)
}

0 comments on commit 149ec44

Please sign in to comment.