in templater/jobs/utils/utils.go [247:270]
func GenerateJobConfig(data interface{}, filePath string) (types.JobConfig, error) {
var jobConfig types.JobConfig
contents, err := ioutil.ReadFile(filePath)
if err != nil {
return jobConfig, fmt.Errorf("error reading job YAML %s: %v", filePath, err)
}
var templatedContents []byte
if data != nil {
templatedContents, err = ExecuteTemplate(string(contents), data)
if err != nil {
return jobConfig, fmt.Errorf("error executing template: %v", err)
}
err = yaml.Unmarshal(templatedContents, &jobConfig)
if err != nil {
return jobConfig, fmt.Errorf("error unmarshaling contents of file %s: %v", filePath, err)
}
} else {
err = yaml.Unmarshal(contents, &jobConfig)
if err != nil {
return jobConfig, fmt.Errorf("error unmarshaling contents of file %s: %v", filePath, err)
}
}
return jobConfig, nil
}