mirror of
https://github.com/kyverno/policy-reporter.git
synced 2024-12-15 17:50:58 +00:00
Merge pull request #338 from djerfy/fix/email-subject-prefix
fix: if clustername is defined (email reports)
This commit is contained in:
commit
083558330e
2 changed files with 23 additions and 4 deletions
|
@ -26,14 +26,23 @@ func (o *Reporter) Report(sources []Source, format string) (email.Report, error)
|
|||
Sources []Source
|
||||
ClusterName string
|
||||
TitlePrefix string
|
||||
}{Sources: sources, ClusterName: o.clusterName, TitlePrefix: o.titlePrefix})
|
||||
}{
|
||||
Sources: sources,
|
||||
ClusterName: o.clusterName,
|
||||
TitlePrefix: o.titlePrefix,
|
||||
})
|
||||
if err != nil {
|
||||
return email.Report{}, err
|
||||
}
|
||||
|
||||
titleCluster := " "
|
||||
if o.clusterName != "" {
|
||||
titleCluster = " on " + o.clusterName + " "
|
||||
}
|
||||
|
||||
return email.Report{
|
||||
ClusterName: o.clusterName,
|
||||
Title: o.titlePrefix + " (summary) on " + o.clusterName + " from " + time.Now().Format("2006-01-02"),
|
||||
Title: o.titlePrefix + " (summary)" + titleCluster + "from " + time.Now().Format("2006-01-02"),
|
||||
Message: b.String(),
|
||||
Format: format,
|
||||
}, nil
|
||||
|
|
|
@ -38,14 +38,24 @@ func (o *Reporter) Report(sources []Source, format string) (email.Report, error)
|
|||
Status []string
|
||||
ClusterName string
|
||||
TitlePrefix string
|
||||
}{Sources: sources, Status: []string{"warn", "fail", "error"}, ClusterName: o.clusterName, TitlePrefix: o.titlePrefix})
|
||||
}{
|
||||
Sources: sources,
|
||||
Status: []string{"warn", "fail", "error"},
|
||||
ClusterName: o.clusterName,
|
||||
TitlePrefix: o.titlePrefix,
|
||||
})
|
||||
if err != nil {
|
||||
return email.Report{}, err
|
||||
}
|
||||
|
||||
titleCluster := " "
|
||||
if o.clusterName != "" {
|
||||
titleCluster = " on " + o.clusterName + " "
|
||||
}
|
||||
|
||||
return email.Report{
|
||||
ClusterName: o.clusterName,
|
||||
Title: o.titlePrefix + " (violations) on " + o.clusterName + " from " + time.Now().Format("2006-01-02"),
|
||||
Title: o.titlePrefix + " (violations)" + titleCluster + "from " + time.Now().Format("2006-01-02"),
|
||||
Message: b.String(),
|
||||
Format: format,
|
||||
}, nil
|
||||
|
|
Loading…
Reference in a new issue