Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/podgrouper/podgrouper/hub/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func (ph *DefaultPluginsHub) GetDefaultPlugin() grouper.Grouper {
}

func (ph *DefaultPluginsHub) HasMatchingPlugin(gvk metav1.GroupVersionKind) bool {
// search using wildcard version - this hub will return a plugin even if the version is not exact match
if _, found := ph.customPlugins[gvk]; found {
return true
}

// search using wildcard version
gvk.Version = "*"
if _, found := ph.customPlugins[gvk]; found {
return true
Expand Down
20 changes: 20 additions & 0 deletions pkg/podgrouper/podgrouper/hub/hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ var _ = Describe("SupportedTypes", func() {
Expect(plugin.Name()).To(BeEquivalentTo("TensorFlow Grouper"))
})

It("should return plugin for exact GVK match - HasMatchingPlugin function", func() {
gvk := metav1.GroupVersionKind{
Group: "kubeflow.org",
Version: "v1",
Kind: "TFJob",
}
hasPlugin := hub.HasMatchingPlugin(gvk)
Expect(hasPlugin).To(BeTrue())
})

It("should return default plugin for non-existent GVK", func() {
gvk := metav1.GroupVersionKind{
Group: "non-existent-group",
Expand All @@ -59,6 +69,16 @@ var _ = Describe("SupportedTypes", func() {
Expect(plugin).NotTo(BeNil())
Expect(plugin.Name()).To(BeEquivalentTo("Default Grouper"))
})

It("non-existent GVK - HasMatchingPlugin returns false", func() {
gvk := metav1.GroupVersionKind{
Group: "non-existent-group",
Version: "v1",
Kind: "NonExistentKind",
}
hasPlugin := hub.HasMatchingPlugin(gvk)
Expect(hasPlugin).To(BeFalse())
})
})

Context("Wildcard Version Tests", func() {
Expand Down
Loading