MCPcopy Index your code
hub / github.com/keploy/keploy / applyTemplateUpdate

Function applyTemplateUpdate

pkg/util.go:2259–2280  ·  view source on GitHub ↗

applyTemplateUpdate writes key=value into currentTemplatedValues, but only when the key already exists (we never invent new template vars at replay time) and the value is actually different from the previous one.

(
	logger *zap.Logger,
	key, value string,
	currentTemplatedValues, prevTemplatedValues map[string]interface{},
	debugPath string,
)

Source from the content-addressed store, hash-verified

2257// already exists (we never invent new template vars at replay time) and the value is
2258// actually different from the previous one.
2259func applyTemplateUpdate(
2260 logger *zap.Logger,
2261 key, value string,
2262 currentTemplatedValues, prevTemplatedValues map[string]interface{},
2263 debugPath string,
2264) bool {
2265 if _, ok := currentTemplatedValues[key]; !ok {
2266 return false
2267 }
2268 prevStr := fmt.Sprintf("%v", prevTemplatedValues[key])
2269 if prevStr == value {
2270 return false
2271 }
2272 logger.Debug("updating template value from header",
2273 zap.String("key", key),
2274 zap.String("path", debugPath),
2275 zap.String("old_value", prevStr),
2276 zap.String("new_value", value),
2277 )
2278 currentTemplatedValues[key] = value
2279 return true
2280}
2281
2282// splitSetCookieLines decomposes a yaml-stored Set-Cookie header into individual cookie lines.
2283// Mirrors the record-side splitSetCookie in pkg/service/tools/templatize.go — kept as a small,

Callers 1

Calls 2

DebugMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected