feat: added MarshalYAML to severities array + issue tracker options fix (#5166)

* feat: added MarshalYAML to severities array

* fix issue with creation of reports
This commit is contained in:
Ice3man 2024-05-10 21:59:03 +05:30 committed by GitHub
parent fed10a11e8
commit 6067b78bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 22 additions and 4 deletions

View File

@ -26,6 +26,14 @@ func (severities *Severities) Set(values string) error {
return nil
}
func (severities Severities) MarshalYAML() (interface{}, error) {
var stringSeverities = make([]string, 0, len(severities))
for _, severity := range severities {
stringSeverities = append(stringSeverities, severity.String())
}
return stringSeverities, nil
}
func (severities *Severities) UnmarshalYAML(unmarshal func(interface{}) error) error {
var stringSliceValue stringslice.StringSlice
if err := unmarshal(&stringSliceValue); err != nil {

View File

@ -74,3 +74,12 @@ func TestMarshalJSON(t *testing.T) {
}
require.Equal(t, "[\"low\",\"medium\"]", string(data), "could not marshal json")
}
func TestSeveritiesMarshalYaml(t *testing.T) {
unmarshalled := Severities{Low, Medium}
marshalled, err := yaml.Marshal(unmarshalled)
if err != nil {
panic(err)
}
require.Equal(t, "- low\n- medium\n", string(marshalled), "could not marshal yaml")
}

View File

@ -276,6 +276,7 @@ func (c *ReportingClient) CreateIssue(event *output.ResultEvent) error {
if tracker.ShouldFilter(event) {
continue
}
trackerName := tracker.Name()
stats, statsOk := c.stats[trackerName]

View File

@ -140,7 +140,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
// ShouldFilter determines if an issue should be logged to this tracker
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
return true
return false
}
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {

View File

@ -176,7 +176,7 @@ func (i *Integration) Name() string {
// ShouldFilter determines if an issue should be logged to this tracker
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
return true
return false
}
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {

View File

@ -165,7 +165,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
// ShouldFilter determines if an issue should be logged to this tracker
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
return true
return false
}
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {

View File

@ -315,7 +315,7 @@ func (i *Integration) FindExistingIssue(event *output.ResultEvent) (jira.Issue,
// ShouldFilter determines if an issue should be logged to this tracker
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
return true
return false
}
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {