MCPcopy Create free account
hub / github.com/featureform/featureform / getSourceMapping

Function getSourceMapping

coordinator/coordinator.go:67–82  ·  view source on GitHub ↗
(template string, replacements map[string]string)

Source from the content-addressed store, hash-verified

65}
66
67func 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
84type Coordinator struct {
85 Metadata *metadata.Client

Callers 3

TestGetSourceMappingFunction · 0.85

Calls 1

sanitizeFunction · 0.70

Tested by 2

TestGetSourceMappingFunction · 0.68