Skip to content

Commit ebc573b

Browse files
arankeparthndeloof
authored andcommitted
refs issue:11706 Resolving the Alias value of Alias type node
Signed-off-by: parth aranke <[email protected]>
1 parent f388192 commit ebc573b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

loader/reset.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package loader
1919
import (
2020
"fmt"
2121
"strconv"
22+
"strings"
2223

2324
"github.com/compose-spec/compose-go/v2/tree"
2425
"gopkg.in/yaml.v3"
@@ -40,6 +41,21 @@ func (p *ResetProcessor) UnmarshalYAML(value *yaml.Node) error {
4041

4142
// resolveReset detects `!reset` tag being set on yaml nodes and record position in the yaml tree
4243
func (p *ResetProcessor) resolveReset(node *yaml.Node, path tree.Path) (*yaml.Node, error) {
44+
// If the path contains "<<", removing the "<<" element and merging the path
45+
if strings.Contains(path.String(), "<<") {
46+
pathArr := strings.Split(path.String(), ".")
47+
path = tree.NewPath(pathArr[0])
48+
for _, el := range pathArr[1:] {
49+
if el != "<<" {
50+
path = tree.Path(strings.Join([]string{path.String(), el}, "."))
51+
}
52+
}
53+
}
54+
// If the node is an alias, We need to process the alias field in order to consider the !override and !reset tags
55+
if node.Kind == yaml.AliasNode {
56+
return p.resolveReset(node.Alias, path)
57+
}
58+
4359
if node.Tag == "!reset" {
4460
p.paths = append(p.paths, path)
4561
return nil, nil

0 commit comments

Comments
 (0)