MCPcopy Create free account
hub / github.com/devspace-sh/devspace / getChildName

Method getChildName

pkg/devspace/config/loader/patch/path.go:20–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18var endsWithBracketExp = regexp.MustCompile(`\[([^\]]+)\]$`)
19
20func (p *OpPath) getChildName() string {
21 path := string(*p)
22 if path == "$" || path == "." {
23 return ""
24 }
25
26 if endsWithBracketExp.MatchString(path) {
27 matches := endsWithBracketExp.FindStringSubmatch(path)
28 if len(matches) > 0 {
29 match := matches[1]
30 match = strings.ReplaceAll(match, `'`, "")
31 match = strings.ReplaceAll(match, `"`, "")
32 return match
33 }
34 return ""
35 }
36
37 tokens := regexp.MustCompile(`\$|\.`).Split(path, -1)
38 if len(tokens) == 0 {
39 return ""
40 }
41
42 return tokens[len(tokens)-1]
43}
44
45func (p *OpPath) getParentPath() string {
46 path := string(*p)

Callers 2

TestGetChildNameFunction · 0.80
PerformMethod · 0.80

Calls

no outgoing calls

Tested by 1

TestGetChildNameFunction · 0.64