3 // PluginCache is an interface implemented by objects that are able to maintain
5 type PluginCache interface {
6 // CachedPluginPath returns a path where the requested plugin is already
7 // cached, or an empty string if the requested plugin is not yet cached.
8 CachedPluginPath(kind string, name string, version Version) string
10 // InstallDir returns the directory that new plugins should be installed into
11 // in order to populate the cache. This directory should be used as the
12 // first argument to getter.Get when downloading plugins with go-getter.
14 // After installing into this directory, use CachedPluginPath to obtain the
15 // path where the plugin was installed.
19 // NewLocalPluginCache returns a PluginCache that caches plugins in a
20 // given local directory.
21 func NewLocalPluginCache(dir string) PluginCache {
27 type pluginCache struct {
31 func (c *pluginCache) CachedPluginPath(kind string, name string, version Version) string {
32 allPlugins := FindPlugins(kind, []string{c.Dir})
33 plugins := allPlugins.WithName(name).WithVersion(version)
35 if plugins.Count() == 0 {
40 // There should generally be only one plugin here; if there's more than
41 // one match for some reason then we'll just choose one arbitrarily.
42 plugin := plugins.Newest()
46 func (c *pluginCache) InstallDir() string {