diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-06-25 12:33:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 12:33:13 -0700 |
commit | 1e5c432e1029601a664454388ae366ef69618d62 (patch) | |
tree | cb9e8bfb66640ac3b29c934bb2c3202d25aeb368 /app/diagnostics.go | |
parent | ecefa6cdd1e7376046bbec82c1b47f7756fea646 (diff) | |
download | chat-1e5c432e1029601a664454388ae366ef69618d62.tar.gz chat-1e5c432e1029601a664454388ae366ef69618d62.tar.bz2 chat-1e5c432e1029601a664454388ae366ef69618d62.zip |
MM-10702 Moving plugins to use hashicorp go-plugin. (#8978)
* Moving plugins to use hashicorp go-plugin.
* Tweaks from feedback.
Diffstat (limited to 'app/diagnostics.go')
-rw-r--r-- | app/diagnostics.go | 85 |
1 files changed, 43 insertions, 42 deletions
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, }) } } |