diff --git a/dispatcher/main.go b/dispatcher/main.go index b97b300..9e5c03f 100644 --- a/dispatcher/main.go +++ b/dispatcher/main.go @@ -105,7 +105,13 @@ func main() { } owners := string(secret.Data["owners"]) - reportutils.Report(run, strings.Split(owners, ",")) + templateURL, ok := secret.Data["email.path.template"] + if ok { + reportutils.Report(run, strings.Split(owners, ","), string(templateURL)) + } else { + common.LogWarning("Failed to get the `email.path.template` value from the kubernetes secret. A generic template will be used instead") + reportutils.Report(run, strings.Split(owners, ","), "") + } run.Status = common.RunStatusCompleted run, err = run.SubmitChange() diff --git a/reportutils/report.go b/reportutils/report.go index 75b1a42..93784d0 100644 --- a/reportutils/report.go +++ b/reportutils/report.go @@ -15,7 +15,7 @@ import ( var httpClient = &http.Client{} // Report method requests the email service to send emails -func Report(run *models.Run, receivers []string) { +func Report(run *models.Run, receivers []string, templateURL string) { common.LogInfo("Sending report...") remark, ok := run.Settings[common.KeyRemark] @@ -31,6 +31,7 @@ func Report(run *models.Run, receivers []string) { content := make(map[string]string) content["run_id"] = strconv.Itoa(run.ID) content["receivers"] = strings.Join(receivers, ",") + content["template"] = templateURL body, err := json.Marshal(content) if err != nil {