Skip to content

Commit 27322e1

Browse files
committed
chore: use constant for n/a action string
1 parent 554415b commit 27322e1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/http/postserver-event.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ func (s *PostServer) postEvent(ctx *gin.Context) {
1616
processPostedEvent(ctx, s.Server, s.postEventCallback)
1717
}
1818

19+
const eventActionNotAvailable = "n/a"
20+
1921
func (s *PostServer) postEventCallback(ctx *gin.Context, postLog logr.Logger, podName string, event *Event) error {
2022
pod := &corev1.Pod{}
2123
err := s.Client.Get(ctx, client.ObjectKey{Namespace: s.Config.Namespace, Name: podName}, pod)
@@ -28,7 +30,7 @@ func (s *PostServer) postEventCallback(ctx *gin.Context, postLog logr.Logger, po
2830

2931
action := event.Action
3032
if action == "" {
31-
action = "N/A"
33+
action = eventActionNotAvailable
3234
}
3335

3436
if len(event.Args) > 0 {

pkg/http/postserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ var _ = Describe("HTTP", func() {
304304
mockSink.EXPECT().WithValues("node", node, "id", executionID).Return(mockSink)
305305
mockSink.EXPECT().WithValues("length", gm.Any()).Return(mockSink)
306306
mockSink.EXPECT().WithValues("pod", gm.Any(), "type", "Warning", "reason", "TestReason", "event-message", "test message: a1").Return(mockSink)
307-
mockRecord.EXPECT().Eventf(gm.Any(), gm.Any(), "Warning", "TestReason", "N/A", "test message: %s", "a1")
307+
mockRecord.EXPECT().Eventf(gm.Any(), gm.Any(), "Warning", "TestReason", eventActionNotAvailable, "test message: %s", "a1")
308308
mockSink.EXPECT().Info(gm.Any(), "event created")
309309
mockReader.EXPECT().
310310
Get(gm.Any(), client.ObjectKey{Namespace: s.Config.Namespace, Name: s.Config.PodName(node, executionID)}, gm.AssignableToTypeOf(&corev1.Pod{}))

0 commit comments

Comments
 (0)