MCPcopy Create free account
hub / github.com/temporalio/temporal / processConfigFile

Function processConfigFile

common/config/loader.go:227–252  ·  view source on GitHub ↗

processConfigFile processes a config file, rendering it as a template if enabled

(data []byte, filename string)

Source from the content-addressed store, hash-verified

225
226// processConfigFile processes a config file, rendering it as a template if enabled
227func processConfigFile(data []byte, filename string) ([]byte, error) {
228 // If the config file contains "enable-template" in a comment within the first 1KB, then
229 // we will treat the file as a template and render it.
230 templating, err := checkTemplatingEnabled(data)
231 if err != nil {
232 return nil, err
233 }
234
235 if !templating {
236 return data, nil
237 }
238
239 stdlog.Printf("Processing config file as template; filename=%v\n", filename)
240 tpl, err := template.New(filename).Funcs(sprig.FuncMap()).Parse(string(data))
241 if err != nil {
242 return nil, err
243 }
244
245 var rendered bytes.Buffer
246 err = tpl.Execute(&rendered, nil)
247 if err != nil {
248 return nil, err
249 }
250
251 return rendered.Bytes(), nil
252}
253
254func loadAndUnmarshalContent(content []byte, filename string, config any) error {
255 processed, err := processConfigFile(content, filename)

Callers 2

loadLegacyMethod · 0.85
loadAndUnmarshalContentFunction · 0.85

Calls 6

checkTemplatingEnabledFunction · 0.85
BytesMethod · 0.80
ParseMethod · 0.65
NewMethod · 0.65
ExecuteMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected