From b219698e758c5108c7124910bfe76ffde99e536f Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Thu, 22 Dec 2016 10:26:04 -0800 Subject: [PATCH] Add a GetAll function that returns only managed plugins supported by V2 The current GetAll handles both V2 and legacy plugins. Also due to the nature of V1 plugins, it also loads them. This causes problems when loading is not required. Hence adding an independent API that will return only the plugins that are loaded using v2 mangaed plugins. Signed-off-by: Madhu Venugopal --- pkg/plugingetter/getter.go | 1 + plugin/store.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/plugingetter/getter.go b/pkg/plugingetter/getter.go index b8096b96b2..dde5f66035 100644 --- a/pkg/plugingetter/getter.go +++ b/pkg/plugingetter/getter.go @@ -30,5 +30,6 @@ type CountedPlugin interface { type PluginGetter interface { Get(name, capability string, mode int) (CompatPlugin, error) GetAllByCap(capability string) ([]CompatPlugin, error) + GetAllManagedPluginsByCap(capability string) []CompatPlugin Handle(capability string, callback func(string, *plugins.Client)) } diff --git a/plugin/store.go b/plugin/store.go index ba0eb03400..7c4cccb037 100644 --- a/plugin/store.go +++ b/plugin/store.go @@ -157,6 +157,11 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug return nil, err } +// GetAllManagedPluginsByCap returns a list of managed plugins matching the given capability. +func (ps *Store) GetAllManagedPluginsByCap(capability string) []plugingetter.CompatPlugin { + return ps.getAllByCap(capability) +} + // GetAllByCap returns a list of enabled plugins matching the given capability. func (ps *Store) GetAllByCap(capability string) ([]plugingetter.CompatPlugin, error) { result := make([]plugingetter.CompatPlugin, 0, 1)