| 164 | } |
| 165 | |
| 166 | func 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 | } |