MCPcopy Create free account
hub / github.com/docker/secrets-engine / replace1

Function replace1

x/secrets/pattern.go:173–186  ·  view source on GitHub ↗
(original, other string)

Source from the content-addressed store, hash-verified

171}
172
173func replace1(original, other string) (string, error) {
174 components := split(original)
175 var candidates []int
176 for idx, val := range components {
177 if val == "**" {
178 candidates = append(candidates, idx)
179 }
180 }
181 if len(candidates) != 1 {
182 return "", fmt.Errorf("expand only supports one expansion glob, pattern %s has %d", original, len(candidates))
183 }
184 components[candidates[0]] = other
185 return strings.Join(components, "/"), nil
186}

Callers 3

Test_applyFunction · 0.85
ExpandIDMethod · 0.85
ExpandPatternMethod · 0.85

Calls 2

splitFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

Test_applyFunction · 0.68