Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 <[email protected]>
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 1 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.

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