From 2168576add93e789966ee0de091042af231a2af5 Mon Sep 17 00:00:00 2001 From: Daniel <69415974+daniel-codefresh@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:51:12 +0200 Subject: [PATCH] fix: Added plural exception for eventbus resource for k8s trigger (#1440) * fix: Added plural exception for eventbus resource for k8s trigger Signed-off-by: Daniel Soifer * fixed test case Signed-off-by: Daniel Soifer --- sensors/triggers/triggers.go | 5 ++++- sensors/triggers/triggers_test.go | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sensors/triggers/triggers.go b/sensors/triggers/triggers.go index d8bcc30c86..8f617eed1c 100644 --- a/sensors/triggers/triggers.go +++ b/sensors/triggers/triggers.go @@ -25,7 +25,10 @@ import ( func GetGroupVersionResource(obj *unstructured.Unstructured) schema.GroupVersionResource { gvk := obj.GroupVersionKind() - resource := namer.NewAllLowercasePluralNamer(nil).Name(&types.Type{ + pluralExceptions := map[string]string{ + "EventBus": "eventbus", + } + resource := namer.NewAllLowercasePluralNamer(pluralExceptions).Name(&types.Type{ Name: types.Name{ Name: gvk.Kind, }, diff --git a/sensors/triggers/triggers_test.go b/sensors/triggers/triggers_test.go index 0352ed0d43..dd35fe86c8 100644 --- a/sensors/triggers/triggers_test.go +++ b/sensors/triggers/triggers_test.go @@ -40,4 +40,12 @@ func TestGetGroupVersionResource(t *testing.T) { Resource: "ingresses", } assert.Equal(t, expectedIngressGVR, GetGroupVersionResource(ingress)) + + eventbus := newUnstructured("argoproj.io/v1alpha1", "EventBus", "fake", "test-eb") + expectedEventBusGVR := schema.GroupVersionResource{ + Group: "argoproj.io", + Version: "v1alpha1", + Resource: "eventbus", + } + assert.Equal(t, expectedEventBusGVR, GetGroupVersionResource(eventbus)) }