BE: Support new policy action type `send_bot_message`
Why are we doing this work
Policy bot comment may be overwhelming for some users and we would like to give users option to disable it. By default, it should be enabled when users create new policies and it should stay enabled by default for older policies that do not have this new action specified in the YML.
Relevant links
Non-functional requirements
-
Documentation: Update documentation to mention the new action type -
Feature flag: Implement the new behavior behind a feature flag -
Testing: Unit tests should be enough to cover the feature
Implementation plan
-
Update JSON schema to add a new type
actions: - type: send_bot_message enabled: true
- Update GeneratePolicyViolationCommentService to check for this action in applicable policies and not post the bot comment if
enabled: false
.- If there's no action, it should be treated as
enabled: true
- If there's no action, it should be treated as
Verification steps
- Create a scan result policy with the
send_bot_message
action disabled:
actions:
- type: send_bot_message
enabled: false
- Create MR in the project with a violation
- Ensure there's no bot comment
- Update the policy and change it to
enabled: true
- Create another MR and ensure the bot message is created
- Update the policy and remove the
send_bot_message
action - Create another MR and ensure the bot message is created
Edited by Alan (Maciej) Paruszewski