| 65 | } |
| 66 | |
| 67 | func getSourceMapping(template string, replacements map[string]string) ([]provider.SourceMapping, error) { |
| 68 | sourceMap := []provider.SourceMapping{} |
| 69 | numEscapes := strings.Count(template, "{{") |
| 70 | for i := 0; i < numEscapes; i++ { |
| 71 | split := strings.SplitN(template, "{{", 2) |
| 72 | afterSplit := strings.SplitN(split[1], "}}", 2) |
| 73 | key := strings.TrimSpace(afterSplit[0]) |
| 74 | replacement, has := replacements[key] |
| 75 | if !has { |
| 76 | return nil, fmt.Errorf("no key set") |
| 77 | } |
| 78 | sourceMap = append(sourceMap, provider.SourceMapping{Template: sanitize(replacement), Source: replacement}) |
| 79 | template = afterSplit[1] |
| 80 | } |
| 81 | return sourceMap, nil |
| 82 | } |
| 83 | |
| 84 | type Coordinator struct { |
| 85 | Metadata *metadata.Client |