github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/plugin/helpers_config.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package plugin
     5  
     6  import (
     7  	"github.com/pkg/errors"
     8  
     9  	"github.com/mattermost/mattermost-server/v5/model"
    10  	"github.com/mattermost/mattermost-server/v5/utils"
    11  )
    12  
    13  // CheckRequiredServerConfiguration implements Helpers.CheckRequiredServerConfiguration
    14  func (p *HelpersImpl) CheckRequiredServerConfiguration(req *model.Config) (bool, error) {
    15  	if req == nil {
    16  		return true, nil
    17  	}
    18  
    19  	cfg := p.API.GetConfig()
    20  
    21  	mc, err := utils.Merge(cfg, req, nil)
    22  	if err != nil {
    23  		return false, errors.Wrap(err, "could not merge configurations")
    24  	}
    25  
    26  	mergedCfg := mc.(model.Config)
    27  	if mergedCfg.ToJson() != cfg.ToJson() {
    28  		return false, nil
    29  	}
    30  
    31  	return true, nil
    32  }