Plugin framework: add ability to install other plugins to the… (#12232)

* add ability to upload other plugins to the plugin API

* generated client rpc glue code

* fix UploadPlugin API signature

* generated plugin mocks

* added upload plugin test

* removed unused comment

* using single line to call InstallPlugin with file Reader

* fix minimum server version

* added successful plugin upload test

* renamed UploadPlugin to InstallPlugin
Этот коммит содержится в:
Nikhil Ranjan
2019-10-17 20:57:55 +02:00
коммит произвёл Ali Farooq
родитель db97b49e7a
Коммит d7ee3553fa
5 изменённых файлов: 119 добавлений и 0 удалений

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

@@ -7,6 +7,8 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"path/filepath"
"strings"
@@ -655,6 +657,19 @@ func (api *PluginAPI) GetPluginStatus(id string) (*model.PluginStatus, *model.Ap
return api.app.GetPluginStatus(id)
}
func (api *PluginAPI) InstallPlugin(file io.Reader, replace bool) (*model.Manifest, *model.AppError) {
if !*api.app.Config().PluginSettings.Enable || !*api.app.Config().PluginSettings.EnableUploads {
return nil, model.NewAppError("installPlugin", "app.plugin.upload_disabled.app_error", nil, "", http.StatusNotImplemented)
}
fileBuffer, err := ioutil.ReadAll(file)
if err != nil {
return nil, model.NewAppError("InstallPlugin", "api.plugin.upload.file.app_error", nil, "", http.StatusBadRequest)
}
return api.app.InstallPlugin(bytes.NewReader(fileBuffer), replace)
}
// KV Store Section
func (api *PluginAPI) KVSet(key string, value []byte) *model.AppError {