MM-28861 Marketplace feature flags (#16451)

* Installing plugins specified by feature flags using the marketplace.

* Switch back to using getplugins client.

* Respect disabling automatic installation of pluings.

* pluginid -> plugin_id

* Debug logs for enable plugin error

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Christopher Speller
2021-01-04 13:21:02 -08:00
коммит произвёл GitHub
родитель 987eddce1f
Коммит b40a93d68b
6 изменённых файлов: 80 добавлений и 1 удалений

Просмотреть файл

@@ -3,6 +3,8 @@
package model
import "reflect"
type FeatureFlags struct {
// Exists only for unit and manual testing.
// When set to a value, will be returned by the ping endpoint.
@@ -13,10 +15,35 @@ type FeatureFlags struct {
// Toggle on and off scheduled jobs for cloud user limit emails see MM-29999
CloudDelinquentEmailJobsEnabled bool
// Feature flags to control plugin versions
PluginIncidentManagement string `plugin_id:"com.mattermost.plugin-incident-management"`
}
func (f *FeatureFlags) SetDefaults() {
f.TestFeature = "off"
f.TestBoolFeature = false
f.CloudDelinquentEmailJobsEnabled = false
f.PluginIncidentManagement = "1.1.1"
}
func (f *FeatureFlags) Plugins() map[string]string {
rFFVal := reflect.ValueOf(f).Elem()
rFFType := reflect.TypeOf(f).Elem()
pluginVersions := make(map[string]string)
for i := 0; i < rFFVal.NumField(); i++ {
rFieldVal := rFFVal.Field(i)
rFieldType := rFFType.Field(i)
pluginId, hasPluginId := rFieldType.Tag.Lookup("plugin_id")
if !hasPluginId {
continue
}
pluginVersions[pluginId] = rFieldVal.String()
}
return pluginVersions
}

Просмотреть файл

@@ -87,6 +87,8 @@ type MarketplacePluginFilter struct {
Cloud bool
LocalOnly bool
Platform string
PluginId string
ReturnAllVersions bool
}
// ApplyToURL modifies the given url to include query string parameters for the request.
@@ -103,6 +105,8 @@ func (filter *MarketplacePluginFilter) ApplyToURL(u *url.URL) {
q.Add("cloud", strconv.FormatBool(filter.Cloud))
q.Add("local_only", strconv.FormatBool(filter.LocalOnly))
q.Add("platform", filter.Platform)
q.Add("plugin_id", filter.PluginId)
q.Add("return_all_versions", strconv.FormatBool(filter.ReturnAllVersions))
u.RawQuery = q.Encode()
}