[MM-35863] Add IsEnterpriseReady Plugin API (#18676)

Automatic Merge
Этот коммит содержится в:
Joe
2021-10-20 11:12:58 +01:00
коммит произвёл GitHub
родитель 5928e4f9e0
Коммит dea8610f1e
6 изменённых файлов: 72 добавлений и 0 удалений

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

@@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"
"github.com/mattermost/mattermost-server/v6/app/request"
@@ -141,6 +142,11 @@ func (api *PluginAPI) GetLicense() *model.License {
return api.app.Srv().License()
}
func (api *PluginAPI) IsEnterpriseReady() bool {
result, _ := strconv.ParseBool(model.BuildEnterpriseReady)
return result
}
func (api *PluginAPI) GetServerVersion() string {
return model.CurrentVersion
}

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

@@ -1922,3 +1922,15 @@ func TestPluginAPIUpdateCommand(t *testing.T) {
require.Equal(t, team1.Id, newCmd4.TeamId)
}
func TestPluginAPIIsEnterpriseReady(t *testing.T) {
oldValue := model.BuildEnterpriseReady
defer func() { model.BuildEnterpriseReady = oldValue }()
model.BuildEnterpriseReady = "true"
th := Setup(t)
defer th.TearDown()
api := th.SetupPluginAPI()
assert.Equal(t, true, api.IsEnterpriseReady())
}

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

@@ -92,6 +92,12 @@ type API interface {
// Minimum server version: 5.10
GetLicense() *model.License
// IsEnterpriseReady returns true if the Mattermost server is configured as Enterprise Ready.
//
// @tag Server
// Minimum server version: 5.10
IsEnterpriseReady() bool
// GetServerVersion return the current Mattermost server version
//
// @tag Server

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

@@ -112,6 +112,13 @@ func (api *apiTimerLayer) GetLicense() *model.License {
return _returnsA
}
func (api *apiTimerLayer) IsEnterpriseReady() bool {
startTime := timePkg.Now()
_returnsA := api.apiImpl.IsEnterpriseReady()
api.recordTime(startTime, "IsEnterpriseReady", true)
return _returnsA
}
func (api *apiTimerLayer) GetServerVersion() string {
startTime := timePkg.Now()
_returnsA := api.apiImpl.GetServerVersion()

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

@@ -980,6 +980,33 @@ func (s *apiRPCServer) GetLicense(args *Z_GetLicenseArgs, returns *Z_GetLicenseR
return nil
}
type Z_IsEnterpriseReadyArgs struct {
}
type Z_IsEnterpriseReadyReturns struct {
A bool
}
func (g *apiRPCClient) IsEnterpriseReady() bool {
_args := &Z_IsEnterpriseReadyArgs{}
_returns := &Z_IsEnterpriseReadyReturns{}
if err := g.client.Call("Plugin.IsEnterpriseReady", _args, _returns); err != nil {
log.Printf("RPC call to IsEnterpriseReady API failed: %s", err.Error())
}
return _returns.A
}
func (s *apiRPCServer) IsEnterpriseReady(args *Z_IsEnterpriseReadyArgs, returns *Z_IsEnterpriseReadyReturns) error {
if hook, ok := s.impl.(interface {
IsEnterpriseReady() bool
}); ok {
returns.A = hook.IsEnterpriseReady()
} else {
return encodableError(fmt.Errorf("API IsEnterpriseReady called but not implemented."))
}
return nil
}
type Z_GetServerVersionArgs struct {
}

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

@@ -2388,6 +2388,20 @@ func (_m *API) InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *mo
return r0, r1
}
// IsEnterpriseReady provides a mock function with given fields:
func (_m *API) IsEnterpriseReady() bool {
ret := _m.Called()
var r0 bool
if rf, ok := ret.Get(0).(func() bool); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// KVCompareAndDelete provides a mock function with given fields: key, oldValue
func (_m *API) KVCompareAndDelete(key string, oldValue []byte) (bool, *model.AppError) {
ret := _m.Called(key, oldValue)