@@ -1549,6 +1549,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob)
1549
1549
1550
1550
func (s * server ) notifyWorkspaceDeleted (ctx context.Context , workspace database.Workspace , build database.WorkspaceBuild ) {
1551
1551
var reason string
1552
+ initiator := build .InitiatorByUsername
1552
1553
if build .Reason .Valid () {
1553
1554
switch build .Reason {
1554
1555
case database .BuildReasonInitiator :
@@ -1560,6 +1561,7 @@ func (s *server) notifyWorkspaceDeleted(ctx context.Context, workspace database.
1560
1561
reason = "initiated by user"
1561
1562
case database .BuildReasonAutodelete :
1562
1563
reason = "autodeleted due to dormancy"
1564
+ initiator = ""
1563
1565
default :
1564
1566
reason = string (build .Reason )
1565
1567
}
@@ -1569,12 +1571,17 @@ func (s *server) notifyWorkspaceDeleted(ctx context.Context, workspace database.
1569
1571
slog .F ("reason" , reason ), slog .F ("workspace_id" , workspace .ID ), slog .F ("build_id" , build .ID ))
1570
1572
}
1571
1573
1574
+ labels := map [string ]string {
1575
+ "name" : workspace .Name ,
1576
+ "reason" : reason ,
1577
+ }
1578
+
1579
+ if initiator != "" {
1580
+ labels ["initiator" ] = initiator
1581
+ }
1582
+
1572
1583
if _ , err := s .NotificationEnqueuer .Enqueue (ctx , workspace .OwnerID , notifications .TemplateWorkspaceDeleted ,
1573
- map [string ]string {
1574
- "name" : workspace .Name ,
1575
- "initiator" : build .InitiatorByUsername ,
1576
- "reason" : reason ,
1577
- }, "provisionerdserver" ,
1584
+ labels , "provisionerdserver" ,
1578
1585
// Associate this notification with all the related entities.
1579
1586
workspace .ID , workspace .OwnerID , workspace .TemplateID , workspace .OrganizationID ,
1580
1587
); err != nil {
0 commit comments