MCPcopy
hub / github.com/spacecloud-io/space-cloud / adjustPath

Function adjustPath

space-cli/cmd/modules/operations/apply.go:166–183  ·  view source on GitHub ↗
(path string, meta map[string]string)

Source from the content-addressed store, hash-verified

164}
165
166func adjustPath(path string, meta map[string]string) (string, error) {
167 newPath := path
168 for {
169 pre := strings.IndexRune(newPath, '{')
170 if pre < 0 {
171 return newPath, nil
172 }
173 post := strings.IndexRune(newPath, '}')
174
175 key := strings.TrimSuffix(strings.TrimPrefix(newPath[pre:post], "{"), "}")
176 value, p := meta[key]
177 if !p {
178 return "", fmt.Errorf("provided key (%s) does not exist in metadata", key)
179 }
180
181 newPath = newPath[:pre] + value + newPath[post+1:]
182 }
183}

Callers 1

ApplySpecFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected