Skip to content

Commit

Permalink
Correct notification routing for DEPLOYMENT_STARTED (#5523)
Browse files Browse the repository at this point in the history
* Correct notification routing for `DEPLOYMENT_STARTED`

Signed-off-by: Yuki Okushi <[email protected]>

* Harden test case

Signed-off-by: Yuki Okushi <[email protected]>

---------

Signed-off-by: Yuki Okushi <[email protected]>
  • Loading branch information
JohnTitor authored Jan 31, 2025
1 parent 7262a8c commit 3021db1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pkg/app/piped/notifier/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ func TestMatch(t *testing.T) {
},
},
}: true,
{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
Metadata: &model.NotificationEventDeploymentStarted{
Deployment: &model.Deployment{
ApplicationName: "bluegreen",
},
},
}: false,
{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
Metadata: &model.NotificationEventDeploymentStarted{
Deployment: &model.Deployment{
ApplicationName: "canary",
},
},
}: true,
},
},
{
Expand Down Expand Up @@ -261,6 +277,28 @@ func TestMatch(t *testing.T) {
},
},
}: true,
{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
Metadata: &model.NotificationEventDeploymentStarted{
Deployment: &model.Deployment{
Labels: map[string]string{
"env": "stg",
"team": "pipecd",
},
},
},
}: false,
{
Type: model.NotificationEventType_EVENT_DEPLOYMENT_STARTED,
Metadata: &model.NotificationEventDeploymentStarted{
Deployment: &model.Deployment{
Labels: map[string]string{
"env": "dev",
"team": "pipecd",
},
},
},
}: true,
},
},
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/model/notificationevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ func (e *NotificationEventDeploymentTriggerFailed) GetLabels() map[string]string
return e.Application.Labels
}

func (e *NotificationEventDeploymentStarted) GetAppName() string {
return e.Deployment.ApplicationName
}

func (e *NotificationEventDeploymentStarted) GetLabels() map[string]string {
return e.Deployment.Labels
}

func (e *NotificationEventApplicationSynced) GetAppName() string {
return e.Application.Name
}
Expand Down

0 comments on commit 3021db1

Please sign in to comment.