Skip to content

Commit

Permalink
Changes for using message instead of description
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
  • Loading branch information
jmle committed Dec 14, 2023
1 parent cf27d93 commit df12caa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions engine/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type Rule struct {
type RuleMeta struct {
RuleID string `yaml:"ruleID,omitempty" json:"ruleID,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Category *konveyor.Category `yaml:"category,omitempty" json:"category,omitempty"`
Labels []string `yaml:"labels,omitempty" json:"labels,omitempty"`
Effort *int `json:"effort,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ func (r *ruleEngine) createViolation(ctx context.Context, conditionResponse Cond

return konveyor.Violation{
Description: rule.Description,
Message: rule.Message,
Labels: rule.Labels,
Category: rule.Category,
Incidents: incidents,
Expand Down
3 changes: 3 additions & 0 deletions output/v1/konveyor/violations.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ type Violation struct {
// TODO: we don't have this in the rule as of today.
Description string `yaml:"description" json:"description"`

// Message a more thorough explanation of the violation
Message string `yaml:"message,omitempty" json:"message,omitempty"`

// Category category of the violation
// TODO: add this to rules
Category *Category `yaml:"category,omitempty" json:"category,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions parser/rule_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ func (r *RuleParser) addRuleFields(rule *engine.Rule, ruleMap map[string]interfa
}
rule.Description = description

message, ok := ruleMap["message"].(string)
if ok {
rule.RuleMeta.Message = message
}

if rule.Perform.Message.Text != nil {
category, ok := ruleMap["category"].(string)
if !ok {
Expand Down

0 comments on commit df12caa

Please sign in to comment.