Skip to content

Commit edcc703

Browse files
JohnTitorpipecd-bot
authored andcommitted
Correct notification routing for DEPLOYMENT_STARTED (#5523)
* Correct notification routing for `DEPLOYMENT_STARTED` Signed-off-by: Yuki Okushi <okushi@canary-inc.jp> * Harden test case Signed-off-by: Yuki Okushi <okushi@canary-inc.jp> --------- Signed-off-by: Yuki Okushi <okushi@canary-inc.jp> Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
1 parent 8ff25b1 commit edcc703

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

pkg/app/piped/notifier/matcher_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ func TestMatch(t *testing.T) {
148148
},
149149
},
150150
}: true,
151+
{
152+
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
153+
Metadata: &model.NotificationEventDeploymentStarted{
154+
Deployment: &model.Deployment{
155+
ApplicationName: "bluegreen",
156+
},
157+
},
158+
}: false,
159+
{
160+
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
161+
Metadata: &model.NotificationEventDeploymentStarted{
162+
Deployment: &model.Deployment{
163+
ApplicationName: "canary",
164+
},
165+
},
166+
}: true,
151167
},
152168
},
153169
{
@@ -261,6 +277,28 @@ func TestMatch(t *testing.T) {
261277
},
262278
},
263279
}: true,
280+
{
281+
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
282+
Metadata: &model.NotificationEventDeploymentStarted{
283+
Deployment: &model.Deployment{
284+
Labels: map[string]string{
285+
"env": "stg",
286+
"team": "pipecd",
287+
},
288+
},
289+
},
290+
}: false,
291+
{
292+
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
293+
Metadata: &model.NotificationEventDeploymentStarted{
294+
Deployment: &model.Deployment{
295+
Labels: map[string]string{
296+
"env": "dev",
297+
"team": "pipecd",
298+
},
299+
},
300+
},
301+
}: true,
264302
},
265303
},
266304
}

pkg/model/notificationevent.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ func (e *NotificationEventDeploymentTriggerFailed) GetLabels() map[string]string
106106
return e.Application.Labels
107107
}
108108

109+
func (e *NotificationEventDeploymentStarted) GetAppName() string {
110+
return e.Deployment.ApplicationName
111+
}
112+
113+
func (e *NotificationEventDeploymentStarted) GetLabels() map[string]string {
114+
return e.Deployment.Labels
115+
}
116+
109117
func (e *NotificationEventApplicationSynced) GetAppName() string {
110118
return e.Application.Name
111119
}

0 commit comments

Comments
 (0)