Introduce TokenDisabled event for WorkflowRuns#19431
Introduce TokenDisabled event for WorkflowRuns#19431hellcp-work wants to merge 1 commit intoopenSUSE:masterfrom
Conversation
b221b71 to
3aba0a8
Compare
| receiver_roles :token_executor, :token_member | ||
| delegate :members, to: :token, prefix: true | ||
|
|
||
| self.notification_explanation = 'Receive notifications for disabled workflow tokens.' |
There was a problem hiding this comment.
I guess this begs the question that people probably want to know about other Token state changes too...
| receiver_roles :token_executor, :token_member | ||
| delegate :members, to: :token, prefix: true | ||
|
|
||
| self.notification_explanation = 'Receive notifications for disabled workflow tokens.' |
There was a problem hiding this comment.
| self.notification_explanation = 'Receive notifications for disabled workflow tokens.' | |
| self.notification_explanation = 'Receive a notification when a workflow token is disabled.' |
| self.notification_explanation = 'Receive notifications for disabled workflow tokens.' | ||
|
|
||
| def subject | ||
| "Workflow Token '#{token.description}' was disabled" |
There was a problem hiding this comment.
| "Workflow Token '#{token.description}' was disabled" | |
| "Workflow Token '#{token.id}' was disabled" |
| @@ -0,0 +1,7 @@ | |||
| %p | |||
| The Workflow Token | |||
| '#{Token.find(event['token_id']).description}' | |||
| %p | ||
| The Workflow Token | ||
| '#{Token.find(event['token_id']).description}' | ||
| was disabled. |
There was a problem hiding this comment.
| was disabled. | |
| was disabled because we encountered authentication problems while reporting workflow status back to the SCM. Please check your setup. |
| self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.' | ||
|
|
||
| def subject | ||
| "Workflow Token '#{token.description}' was disabled automatically" |
There was a problem hiding this comment.
| "Workflow Token '#{token.description}' was disabled automatically" | |
| "Workflow Token '#{token.id}' was disabled automatically" |
| receiver_roles :token_executor, :token_member | ||
| delegate :members, to: :token, prefix: true | ||
|
|
||
| self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.' |
There was a problem hiding this comment.
| self.notification_explanation = 'Receive notifications for workflow tokens disabled automatically.' | |
| self.notification_explanation = 'Receive notifications when a workflow token gets disabled.' |
| %p | ||
| The Workflow Token | ||
| '#{Token.find(event['token_id']).description}' | ||
| was automatically disabled due to a failed call to the SCM. |
There was a problem hiding this comment.
| was automatically disabled due to a failed call to the SCM. | |
| was automatically disabled due to authorization problems when reporting workflow status to Gihub/Gitlab/Gitea. Please check your setup. |
| @@ -0,0 +1,3 @@ | |||
| The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to a failed call to the SCM. | |||
There was a problem hiding this comment.
| The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to a failed call to the SCM. | |
| The Workflow Token '<%= Token.find(event['token_id']).description %>' was automatically disabled due to authorization problems when reporting workflow status to Gihub/Gitlab/Gitea. Please check your setup. |
e6c2648 to
f7747f7
Compare
| token_enabled = token.enabled | ||
| if token.update(xml_attributes) | ||
| Event::TokenDisabled.create(id: token.workflow_runs.first&.id, token_id: token.id, user_id: @user.id, reason: "Disabled by #{@user.login}.") if token_enabled && !token.enabled |
There was a problem hiding this comment.
This sounds like Token (callback) code to me to be honest.
There was a problem hiding this comment.
I'm worried about triggering this twice in case of the detected automated token disablement
There was a problem hiding this comment.
What exactly are you worried about?
There was a problem hiding this comment.
If we do it when the change is triggered on the after save level and then trigger it on the change happens in the automated way in another model, we end up with two events for the same action
There was a problem hiding this comment.
To know what the reason for the change was
There was a problem hiding this comment.
See the commit_opts pattern in Project for instance...
405443f to
e7b0054
Compare
e7b0054 to
e62dfc5
Compare
| @@ -0,0 +1,52 @@ | |||
| module Event | |||
| class TokenDisabled < Base | |||
There was a problem hiding this comment.
Time to rename this event and also notify when the token is enabled again.
Fixes #18886