Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use time type instead of a preformatted string for times in notification template #665

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dkron/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/textproto"
"strings"
"text/template"
"time"

"github.com/jordan-wright/email"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -74,17 +75,17 @@ func (n *Notifier) buildTemplate(templ string) *bytes.Buffer {
Report string
JobName string
ReportingNode string
StartTime string
FinishedAt string
StartTime time.Time
FinishedAt time.Time
Success string
NodeName string
Output string
}{
n.report(),
n.Execution.JobName,
n.Config.NodeName,
fmt.Sprintf("%s", n.Execution.StartedAt),
fmt.Sprintf("%s", n.Execution.FinishedAt),
n.Execution.StartedAt,
n.Execution.FinishedAt,
fmt.Sprintf("%t", n.Execution.Success),
n.Execution.NodeName,
fmt.Sprintf("%s", n.Execution.Output),
Expand Down
4 changes: 2 additions & 2 deletions dkron/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ var templateTestCases = func(n *Notifier) []templateTestCase {
},
{
desc: "StartTime template variable",
exp: fmt.Sprintf("%s", n.Execution.StartedAt),
exp: n.Execution.StartedAt.String(),
template: "{{.StartTime}}",
},
{
desc: "FinishedAt template variable",
exp: fmt.Sprintf("%s", n.Execution.FinishedAt),
exp: n.Execution.FinishedAt.String(),
template: "{{.FinishedAt}}",
},
{
Expand Down