1
0
Fork 0
mirror of https://github.com/kyverno/policy-reporter.git synced 2024-12-14 11:57:32 +00:00

Merge pull request #338 from djerfy/fix/email-subject-prefix

fix: if clustername is defined (email reports)
This commit is contained in:
Frank Jogeleit 2023-08-31 10:52:22 +02:00 committed by GitHub
commit 083558330e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View file

@ -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

View file

@ -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