From 069727469553e6827a18643c1595172434c1e831 Mon Sep 17 00:00:00 2001 From: woodsaj Date: Sat, 5 Dec 2015 01:20:42 +0800 Subject: [PATCH] I add plugin dependency check. This check ensures that all of the plugins required by a bundle are loaded. --- pkg/plugins/plugins.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index 935e3bf9c21..3e3a9d85152 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -35,9 +35,30 @@ func Init() error { scan(path.Join(setting.StaticRootPath, "app/plugins")) checkExternalPluginPaths() + checkDependencies() return nil } +func checkDependencies() { + for bundleType, bundle := range Bundles { + for _, reqPanel := range bundle.PanelPlugins { + if _, ok := Panels[reqPanel]; !ok { + log.Fatal(4, "Bundle %s requires Panel type %s, but it is not present.", bundleType, reqPanel) + } + } + for _, reqDataSource := range bundle.DatasourcePlugins { + if _, ok := DataSources[reqDataSource]; !ok { + log.Fatal(4, "Bundle %s requires DataSource type %s, but it is not present.", bundleType, reqDataSource) + } + } + for _, reqExtPlugin := range bundle.ExternalPlugins { + if _, ok := ExternalPlugins[reqExtPlugin]; !ok { + log.Fatal(4, "Bundle %s requires DataSource type %s, but it is not present.", bundleType, reqExtPlugin) + } + } + } +} + func checkExternalPluginPaths() error { for _, section := range setting.Cfg.Sections() { if strings.HasPrefix(section.Name(), "plugin.") {