mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
Fix datetime in checker reports
* Change how the datetime is generated for the report. Co-authored-by: Bernhard Reiter <bernhard@intevation.de>
This commit is contained in:
parent
57fc012ec2
commit
6ec2131f5d
3 changed files with 21 additions and 10 deletions
|
|
@ -192,7 +192,10 @@ func (p *processor) clean() {
|
||||||
// It returns a pointer to the report and nil, otherwise an error.
|
// It returns a pointer to the report and nil, otherwise an error.
|
||||||
func (p *processor) run(reporters []reporter, domains []string) (*Report, error) {
|
func (p *processor) run(reporters []reporter, domains []string) (*Report, error) {
|
||||||
|
|
||||||
var report Report
|
report := Report{
|
||||||
|
Date: ReportTime{Time: time.Now().UTC()},
|
||||||
|
Version: util.SemVersion,
|
||||||
|
}
|
||||||
|
|
||||||
for _, d := range domains {
|
for _, d := range domains {
|
||||||
if err := p.checkDomain(d); err != nil {
|
if err := p.checkDomain(d); err != nil {
|
||||||
|
|
@ -205,9 +208,6 @@ func (p *processor) run(reporters []reporter, domains []string) (*Report, error)
|
||||||
for _, r := range reporters {
|
for _, r := range reporters {
|
||||||
r.report(p, domain)
|
r.report(p, domain)
|
||||||
}
|
}
|
||||||
report.Version = util.SemVersion
|
|
||||||
now := time.Now()
|
|
||||||
report.Date = now.Format("2006-01-02T15:04:05Z")
|
|
||||||
report.Domains = append(report.Domains, domain)
|
report.Domains = append(report.Domains, domain)
|
||||||
p.clean()
|
p.clean()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// MessageType is the kind of the message.
|
// MessageType is the kind of the message.
|
||||||
type MessageType int
|
type MessageType int
|
||||||
|
|
@ -41,11 +44,19 @@ type Domain struct {
|
||||||
Requirements []*Requirement `json:"requirements,omitempty"`
|
Requirements []*Requirement `json:"requirements,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReportTime stores the time of the report.
|
||||||
|
type ReportTime struct{ time.Time }
|
||||||
|
|
||||||
// Report is the overall report.
|
// Report is the overall report.
|
||||||
type Report struct {
|
type Report struct {
|
||||||
Domains []*Domain `json:"domains,omitempty"`
|
Domains []*Domain `json:"domains,omitempty"`
|
||||||
Version string `json:"version,omitempty"`
|
Version string `json:"version,omitempty"`
|
||||||
Date string `json:"date,omitempty"`
|
Date ReportTime `json:"date,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText implements the encoding.TextMarshaller interface.
|
||||||
|
func (rt ReportTime) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(rt.Format(time.RFC3339)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasErrors tells if this requirement has errors.
|
// HasErrors tells if this requirement has errors.
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Date of run: <time datetime="{{.Date}}">{{.Date}}</time>
|
Date of run: <time datetime="{{.Date.Format "2006-01-02T15:04:05Z"}}">{{ .Date.Format "2006-01-02T15:04:05Z" }}</time>
|
||||||
csaf_checker v<span class="version">{{ .Version }}</span>
|
csaf_checker v<span class="version">{{ .Version }}</span>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue