Adds support to a tree hierarchy of kubectl plugins

This commit is contained in:
Fabiano Franz
2017-05-05 19:22:24 -03:00
parent 8594af7676
commit da85262f70
5 changed files with 126 additions and 14 deletions

View File

@@ -88,8 +88,15 @@ func (l *DirectoryPluginLoader) Load() (Plugins, error) {
return nil
}
plugin.Dir = filepath.Dir(path)
plugin.DescriptorName = fileInfo.Name()
var setSource func(path string, fileInfo os.FileInfo, p *Plugin)
setSource = func(path string, fileInfo os.FileInfo, p *Plugin) {
p.Dir = filepath.Dir(path)
p.DescriptorName = fileInfo.Name()
for _, child := range p.Tree {
setSource(path, fileInfo, child)
}
}
setSource(path, fileInfo, plugin)
glog.V(6).Infof("Plugin loaded: %s", plugin.Name)
list = append(list, plugin)