MCPcopy
hub / github.com/keploy/keploy / mergeStrings

Function mergeStrings

config/default.go:167–190  ·  view source on GitHub ↗

Reference: https://github.com/kubernetes-sigs/kustomize/blob/537c4fa5c2bf3292b273876f50c62ce1c81714d7/kyaml/yaml/merge2/merge2.go#L24 VisitKeysAsScalars is set to true to enable merging comments. inferAssociativeLists is set to fasle to disable merging associative lists.

(srcStr, destStr string, infer bool, mergeOptions yaml.MergeOptions)

Source from the content-addressed store, hash-verified

165// VisitKeysAsScalars is set to true to enable merging comments.
166// inferAssociativeLists is set to fasle to disable merging associative lists.
167func mergeStrings(srcStr, destStr string, infer bool, mergeOptions yaml.MergeOptions) (string, error) {
168 src, err := yaml.Parse(srcStr)
169 if err != nil {
170 return "", err
171 }
172
173 dest, err := yaml.Parse(destStr)
174 if err != nil {
175 return "", err
176 }
177
178 result, err := walk.Walker{
179 Sources: []*yaml.RNode{dest, src},
180 Visitor: merge2.Merger{},
181 InferAssociativeLists: infer,
182 VisitKeysAsScalars: true,
183 MergeOptions: mergeOptions,
184 }.Walk()
185 if err != nil {
186 return "", err
187 }
188
189 return result.String()
190}

Callers 1

MergeFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected