Procházet zdrojové kódy

I add plugin dependency check.

This check ensures that all of the plugins required by a bundle
are loaded.
woodsaj před 10 roky
rodič
revize
0697274695
1 změnil soubory, kde provedl 21 přidání a 0 odebrání
  1. 21 0
      pkg/plugins/plugins.go

+ 21 - 0
pkg/plugins/plugins.go

@@ -35,9 +35,30 @@ func Init() error {
 
 
 	scan(path.Join(setting.StaticRootPath, "app/plugins"))
 	scan(path.Join(setting.StaticRootPath, "app/plugins"))
 	checkExternalPluginPaths()
 	checkExternalPluginPaths()
+	checkDependencies()
 	return nil
 	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 {
 func checkExternalPluginPaths() error {
 	for _, section := range setting.Cfg.Sections() {
 	for _, section := range setting.Cfg.Sections() {
 		if strings.HasPrefix(section.Name(), "plugin.") {
 		if strings.HasPrefix(section.Name(), "plugin.") {