From 1e5c432e1029601a664454388ae366ef69618d62 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 25 Jun 2018 12:33:13 -0700 Subject: MM-10702 Moving plugins to use hashicorp go-plugin. (#8978) * Moving plugins to use hashicorp go-plugin. * Tweaks from feedback. --- app/diagnostics.go | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) (limited to 'app/diagnostics.go') diff --git a/app/diagnostics.go b/app/diagnostics.go index d833cdbec..c37d7d339 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -559,59 +559,60 @@ func (a *App) trackLicense() { } func (a *App) trackPlugins() { - if *a.Config().PluginSettings.Enable { - totalActiveCount := -1 // -1 to indicate disabled or error - webappActiveCount := 0 - backendActiveCount := 0 - totalInactiveCount := -1 // -1 to indicate disabled or error - webappInactiveCount := 0 - backendInactiveCount := 0 + if a.PluginsReady() { + totalEnabledCount := 0 + webappEnabledCount := 0 + backendEnabledCount := 0 + totalDisabledCount := 0 + webappDisabledCount := 0 + backendDisabledCount := 0 + brokenManifestCount := 0 settingsCount := 0 - plugins, _ := a.GetPlugins() + pluginStates := a.Config().PluginSettings.PluginStates + plugins, _ := a.Plugins.Available() - if plugins != nil { - totalActiveCount = len(plugins.Active) - - for _, plugin := range plugins.Active { - if plugin.Webapp != nil { - webappActiveCount += 1 - } - - if plugin.Backend != nil { - backendActiveCount += 1 - } - - if plugin.SettingsSchema != nil { - settingsCount += 1 + if pluginStates != nil && plugins != nil { + for _, plugin := range plugins { + if plugin.Manifest == nil { + brokenManifestCount += 1 + continue } - } - - totalInactiveCount = len(plugins.Inactive) - - for _, plugin := range plugins.Inactive { - if plugin.Webapp != nil { - webappInactiveCount += 1 + if state, ok := pluginStates[plugin.Manifest.Id]; ok && state.Enable { + totalEnabledCount += 1 + if plugin.Manifest.Backend != nil { + backendEnabledCount += 1 + } + if plugin.Manifest.Webapp != nil { + webappEnabledCount += 1 + } + } else { + totalDisabledCount += 1 + if plugin.Manifest.Backend != nil { + backendDisabledCount += 1 + } + if plugin.Manifest.Webapp != nil { + webappDisabledCount += 1 + } } - - if plugin.Backend != nil { - backendInactiveCount += 1 - } - - if plugin.SettingsSchema != nil { + if plugin.Manifest.SettingsSchema != nil { settingsCount += 1 } } + } else { + totalEnabledCount = -1 // -1 to indicate disabled or error + totalDisabledCount = -1 // -1 to indicate disabled or error } a.SendDiagnostic(TRACK_PLUGINS, map[string]interface{}{ - "active_plugins": totalActiveCount, - "active_webapp_plugins": webappActiveCount, - "active_backend_plugins": backendActiveCount, - "inactive_plugins": totalInactiveCount, - "inactive_webapp_plugins": webappInactiveCount, - "inactive_backend_plugins": backendInactiveCount, - "plugins_with_settings": settingsCount, + "enabled_plugins": totalEnabledCount, + "enabled_webapp_plugins": webappEnabledCount, + "enabled_backend_plugins": backendEnabledCount, + "disabled_plugins": totalDisabledCount, + "disabled_webapp_plugins": webappDisabledCount, + "disabled_backend_plugins": backendDisabledCount, + "plugins_with_settings": settingsCount, + "plugins_with_broken_manifests": brokenManifestCount, }) } } -- cgit v1.2.3-1-g7c22