github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/syz-cluster/pkg/report/email.go (about)

     1  // Copyright 2025 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package report
     5  
     6  import (
     7  	"bytes"
     8  	"embed"
     9  	"text/template"
    10  
    11  	"github.com/google/syzkaller/syz-cluster/pkg/api"
    12  	"github.com/google/syzkaller/syz-cluster/pkg/app"
    13  )
    14  
    15  //go:embed template.txt
    16  var templateFS embed.FS
    17  
    18  func Render(rep *api.SessionReport, config *app.EmailConfig) ([]byte, error) {
    19  	tmpl, err := template.ParseFS(templateFS, "template.txt")
    20  	if err != nil {
    21  		return nil, err
    22  	}
    23  	data := struct {
    24  		Report *api.SessionReport
    25  		Config *app.EmailConfig
    26  	}{
    27  		Report: rep,
    28  		Config: config,
    29  	}
    30  	var buf bytes.Buffer
    31  	if err := tmpl.Execute(&buf, data); err != nil {
    32  		return nil, err
    33  	}
    34  	return buf.Bytes(), nil
    35  }