Skip to content

Commit 119b51a

Browse files
committed
fix: Send Failed status when erroring
- Caller should switch on Type == Failed, not Error != nil - Error should always be non-nil for Failed and Skipped events
1 parent 825458e commit 119b51a

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

pkg/apply/prune/event-factory.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (pef PruneEventFactory) CreateFailedEvent(id object.ObjMetadata, err error)
6868
Type: event.PruneType,
6969
PruneEvent: event.PruneEvent{
7070
GroupName: pef.groupName,
71+
Status: event.PruneFailed,
7172
Identifier: id,
7273
Error: err,
7374
},
@@ -110,6 +111,7 @@ func (def DeleteEventFactory) CreateFailedEvent(id object.ObjMetadata, err error
110111
Type: event.DeleteType,
111112
DeleteEvent: event.DeleteEvent{
112113
GroupName: def.groupName,
114+
Status: event.DeleteFailed,
113115
Identifier: id,
114116
Error: err,
115117
},

pkg/apply/prune/prune_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ func TestPruneWithErrors(t *testing.T) {
697697
EventType: event.PruneType,
698698
PruneEvent: &testutil.ExpPruneEvent{
699699
Identifier: object.UnstructuredToObjMetadata(pdbDeleteFailure),
700+
Status: event.PruneFailed,
700701
Error: fmt.Errorf("expected delete error"),
701702
},
702703
},
@@ -710,6 +711,7 @@ func TestPruneWithErrors(t *testing.T) {
710711
EventType: event.DeleteType,
711712
DeleteEvent: &testutil.ExpDeleteEvent{
712713
Identifier: object.UnstructuredToObjMetadata(pdbDeleteFailure),
714+
Status: event.DeleteFailed,
713715
Error: fmt.Errorf("expected delete error"),
714716
},
715717
},

pkg/apply/task/apply_task.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ func (a *ApplyTask) createApplyFailedEvent(id object.ObjMetadata, err error) eve
251251
ApplyEvent: event.ApplyEvent{
252252
GroupName: a.Name(),
253253
Identifier: id,
254+
Status: event.ApplyFailed,
254255
Error: err,
255256
},
256257
}

pkg/apply/task/apply_task_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ func TestApplyTaskWithError(t *testing.T) {
412412
{
413413
Type: event.ApplyType,
414414
ApplyEvent: event.ApplyEvent{
415-
Error: fmt.Errorf("expected apply error"),
415+
Status: event.ApplyFailed,
416+
Error: fmt.Errorf("expected apply error"),
416417
},
417418
},
418419
},

test/e2e/continue_on_error_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
7373
EventType: event.ApplyType,
7474
ApplyEvent: &testutil.ExpApplyEvent{
7575
GroupName: "apply-0",
76+
Status: event.ApplyFailed,
7677
Identifier: object.UnstructuredToObjMetadata(invalidCrdObj),
7778
Error: testutil.EqualErrorType(
7879
applyerror.NewApplyRunError(errors.New("failed to apply")),

0 commit comments

Comments
 (0)