GoogleCloudPlatform / security-response-automation

Take automated actions against threats and vulnerabilities.
Apache License 2.0
209 stars 52 forks source link

Add template service #73

Closed diegogr-cit closed 4 years ago

diegogr-cit commented 4 years ago

@tomscript,

As mentioned in #39 I include here html/template abstraction to be used on template.

//Template: "Hello Admin, {{.Content}}"

fileName := "template.tmpl"
body := struct {
    Content string
}{
    Content: "body message",
}

//Use by template entity:
tmpl := NewTemplate(fileName)
res, err := tmpl.Render(body)

//Using by email entity:
email = NewEmail(service)
email.RenderTemplate("template.tmpl", body)

Just to organize I moved the common interface/response code from Email Client to client/email.go and extract external specific code to email_sendgrid.go, lmk if what you think.