File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
pkg/podgrouper/podgrouper/hub Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ func (ph *DefaultPluginsHub) GetDefaultPlugin() grouper.Grouper {
8282}
8383
8484func (ph * DefaultPluginsHub ) HasMatchingPlugin (gvk metav1.GroupVersionKind ) bool {
85- // search using wildcard version - this hub will return a plugin even if the version is not exact match
85+ if _ , found := ph .customPlugins [gvk ]; found {
86+ return true
87+ }
88+
89+ // search using wildcard version
8690 gvk .Version = "*"
8791 if _ , found := ph .customPlugins [gvk ]; found {
8892 return true
Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ var _ = Describe("SupportedTypes", func() {
4949 Expect (plugin .Name ()).To (BeEquivalentTo ("TensorFlow Grouper" ))
5050 })
5151
52+ It ("should return plugin for exact GVK match - HasMatchingPlugin function" , func () {
53+ gvk := metav1.GroupVersionKind {
54+ Group : "kubeflow.org" ,
55+ Version : "v1" ,
56+ Kind : "TFJob" ,
57+ }
58+ hasPlugin := hub .HasMatchingPlugin (gvk )
59+ Expect (hasPlugin ).To (BeTrue ())
60+ })
61+
5262 It ("should return default plugin for non-existent GVK" , func () {
5363 gvk := metav1.GroupVersionKind {
5464 Group : "non-existent-group" ,
@@ -59,6 +69,16 @@ var _ = Describe("SupportedTypes", func() {
5969 Expect (plugin ).NotTo (BeNil ())
6070 Expect (plugin .Name ()).To (BeEquivalentTo ("Default Grouper" ))
6171 })
72+
73+ It ("non-existent GVK - HasMatchingPlugin returns false" , func () {
74+ gvk := metav1.GroupVersionKind {
75+ Group : "non-existent-group" ,
76+ Version : "v1" ,
77+ Kind : "NonExistentKind" ,
78+ }
79+ hasPlugin := hub .HasMatchingPlugin (gvk )
80+ Expect (hasPlugin ).To (BeFalse ())
81+ })
6282 })
6383
6484 Context ("Wildcard Version Tests" , func () {
You can’t perform that action at this time.
0 commit comments