Skip to content

Commit

Permalink
fix: Added plural exception for eventbus resource for k8s trigger (#1440
Browse files Browse the repository at this point in the history
)

* fix: Added plural exception for eventbus resource for k8s trigger

Signed-off-by: Daniel Soifer <[email protected]>

* fixed test case

Signed-off-by: Daniel Soifer <[email protected]>
  • Loading branch information
daniel-codefresh authored Nov 29, 2021
1 parent 9265d8e commit 2168576
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sensors/triggers/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
8 changes: 8 additions & 0 deletions sensors/triggers/triggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 2168576

Please sign in to comment.