MCPcopy Create free account
hub / github.com/compose-spec/compose-go / importResource

Function importResource

loader/include.go:190–223  ·  view source on GitHub ↗
(source map[string]any, target map[string]any, key string, processor PostProcessor)

Source from the content-addressed store, hash-verified

188}
189
190func importResource(source map[string]any, target map[string]any, key string, processor PostProcessor) error {
191 from := source[key]
192 if from != nil {
193 var to map[string]any
194 if v, ok := target[key]; ok {
195 to = v.(map[string]any)
196 } else {
197 to = map[string]any{}
198 }
199 for name, a := range from.(map[string]any) {
200 conflict, ok := to[name]
201 if !ok {
202 to[name] = a
203 continue
204 }
205 err := processor.Apply(map[string]any{
206 key: map[string]any{
207 name: a,
208 },
209 })
210 if err != nil {
211 return err
212 }
213
214 merged, err := override.MergeYaml(a, conflict, tree.NewPath(key, name))
215 if err != nil {
216 return err
217 }
218 to[name] = merged
219 }
220 target[key] = to
221 }
222 return nil
223}

Callers 1

importResourcesFunction · 0.85

Calls 3

MergeYamlFunction · 0.92
NewPathFunction · 0.92
ApplyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…