[MM-58378] Prevent prepackaged playbook v2 from upgrading on servers without enterprise license (#27335)
* add check for playbooks v2 * add new license helper --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -964,6 +964,8 @@ func (ch *Channels) processPrepackagedPlugins(prepackagedPluginsDir string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
var SemVerV2 = semver.MustParse("2.0.0")
|
||||
|
||||
// processPrepackagedPlugin will return the prepackaged plugin metadata and will also
|
||||
// install the prepackaged plugin if it had been previously enabled and AutomaticPrepackagedPlugins is true.
|
||||
func (ch *Channels) processPrepackagedPlugin(pluginPath *pluginSignaturePath) (*plugin.PrepackagedPlugin, error) {
|
||||
@@ -990,6 +992,21 @@ func (ch *Channels) processPrepackagedPlugin(pluginPath *pluginSignaturePath) (*
|
||||
|
||||
logger = logger.With(mlog.String("plugin_id", plugin.Manifest.Id))
|
||||
|
||||
if plugin.Manifest.Id == model.PluginIdPlaybooks {
|
||||
version, err := semver.Parse(plugin.Manifest.Version)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Unable to verify prepackaged playbooks version")
|
||||
}
|
||||
if version.GTE(SemVerV2) {
|
||||
license := ch.License()
|
||||
canUsePlaybookv2 := license != nil && license.IsE20OrEnterprise()
|
||||
if !canUsePlaybookv2 {
|
||||
logger.Info("Skip installing prepackaged playbooks because the license does not allow it")
|
||||
return plugin, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Skip installing the plugin at all if automatic prepackaged plugins is disabled
|
||||
if !*ch.cfgSvc.Config().PluginSettings.AutomaticPrepackagedPlugins {
|
||||
logger.Info("Not installing prepackaged plugin: automatic prepackaged plugins disabled")
|
||||
|
||||
@@ -385,6 +385,11 @@ func (l *License) HasSharedChannels() bool {
|
||||
l.SkuShortName == LicenseShortSkuEnterprise
|
||||
}
|
||||
|
||||
// IsE20OrEnterprise returns true when the license is for E20 or Enterprise.
|
||||
func (l *License) IsE20OrEnterprise() bool {
|
||||
return l.SkuShortName == LicenseShortSkuE20 || l.SkuShortName == LicenseShortSkuEnterprise
|
||||
}
|
||||
|
||||
// NewTestLicense returns a license that expires in the future and has the given features.
|
||||
func NewTestLicense(features ...string) *License {
|
||||
ret := &License{
|
||||
|
||||
Ссылка в новой задаче
Block a user