Skip to content

[Stage Plugins] Define Notifier APIs of Approved and WaitApproval#5538

Closed
t-kikuc wants to merge 1 commit intomasterfrom
plugin/notifier-1c_define-api-split
Closed

[Stage Plugins] Define Notifier APIs of Approved and WaitApproval#5538
t-kikuc wants to merge 1 commit intomasterfrom
plugin/notifier-1c_define-api-split

Conversation

@t-kikuc
Copy link
Member

@t-kikuc t-kikuc commented Feb 4, 2025

What this PR does:

as title

Why we need it:

The WaitApproval plugin needs to:

  • notify approvers when the stage starts (NotificationEventDeploymentWaitApproval)
  • notify when approval is completed (NotificationEventDeploymentApproved)

cf.

func (e *Executor) reportApproved(approver string) {
users, groups, err := e.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_APPROVED)
if err != nil {
e.Logger.Error("failed to get the list of users or groups", zap.Error(err))
}
e.Notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_APPROVED,
Metadata: &model.NotificationEventDeploymentApproved{
Deployment: e.Deployment,
Approver: approver,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}
func (e *Executor) reportRequiringApproval() {
users, groups, err := e.getApplicationNotificationMentions(model.NotificationEventType_EVENT_DEPLOYMENT_WAIT_APPROVAL)
if err != nil {
e.Logger.Error("failed to get the list of users or groups", zap.Error(err))
}
e.Notifier.Notify(model.NotificationEvent{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_WAIT_APPROVAL,
Metadata: &model.NotificationEventDeploymentWaitApproval{
Deployment: e.Deployment,
MentionedAccounts: users,
MentionedGroups: groups,
},
})
}

They depend on the current matcher/sender configs.

Note

  • Other notifications must NOT be triggered by plugins (e.g. DeploymentStarted, StageFinished)

  • If a plugin wants to send other customized notifications, the plugin should do so within the plugin without the pipedservice.

  • These pipedservice methods can be used by other plugins

    • e.g. customized notification plugin
    • The advantage of using them over full-scratch notifications is that the current matcher/sender can be used.

Which issue(s) this PR fixes:

Part of #5367

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
@codecov
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.44%. Comparing base (4411ffb) to head (1fe8a7d).
Report is 59 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5538   +/-   ##
=======================================
  Coverage   26.43%   26.44%           
=======================================
  Files         465      465           
  Lines       49858    49858           
=======================================
+ Hits        13182    13186    +4     
+ Misses      35621    35618    -3     
+ Partials     1055     1054    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@t-kikuc t-kikuc closed this Feb 26, 2025
@t-kikuc
Copy link
Member Author

t-kikuc commented Feb 26, 2025

I'll refine in another PR.
accounts/groups should not be touched in plugin side

@khanhtc1202 khanhtc1202 deleted the plugin/notifier-1c_define-api-split branch April 18, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant