[MM-16376] Allow server to download and install a plugin from… (#11372)
* Initial implementation of plugin remote source * Implement API route * Test API route * Add i18n * Handle different error cases in API route * Include missing i18n translation * Include AllowInsecureDownloadUrl in telemetry capture * Updates from PR feedback * Use HTTPService instead of http.Get * Remove InstallPluginFromUrlForced from client4 * Use net/url library to inspect url scheme * remove PluginDownloadUrl from web/params.go * Allow plugin downloads from internal sources
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
44b9fe3110
Коммит
8cdf5ffe67
@@ -4263,6 +4263,21 @@ func (c *Client4) uploadPlugin(file io.Reader, force bool) (*Manifest, *Response
|
||||
return ManifestFromJson(rp.Body), BuildResponse(rp)
|
||||
}
|
||||
|
||||
func (c *Client4) InstallPluginFromUrl(downloadUrl string, force bool) (*Manifest, *Response) {
|
||||
forceStr := "false"
|
||||
if force {
|
||||
forceStr = "true"
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s?plugin_download_url=%s&force=%s", c.GetPluginsRoute()+"/install_from_url", url.QueryEscape(downloadUrl), forceStr)
|
||||
r, err := c.DoApiPost(url, "")
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
}
|
||||
defer closeBody(r)
|
||||
return ManifestFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetPlugins will return a list of plugin manifests for currently active plugins.
|
||||
// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
|
||||
func (c *Client4) GetPlugins() (*PluginsResponse, *Response) {
|
||||
|
||||
@@ -2183,12 +2183,13 @@ type PluginState struct {
|
||||
}
|
||||
|
||||
type PluginSettings struct {
|
||||
Enable *bool
|
||||
EnableUploads *bool `restricted:"true"`
|
||||
Directory *string `restricted:"true"`
|
||||
ClientDirectory *string `restricted:"true"`
|
||||
Plugins map[string]map[string]interface{}
|
||||
PluginStates map[string]*PluginState
|
||||
Enable *bool
|
||||
EnableUploads *bool `restricted:"true"`
|
||||
AllowInsecureDownloadUrl *bool `restricted:"true"`
|
||||
Directory *string `restricted:"true"`
|
||||
ClientDirectory *string `restricted:"true"`
|
||||
Plugins map[string]map[string]interface{}
|
||||
PluginStates map[string]*PluginState
|
||||
}
|
||||
|
||||
func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
||||
@@ -2200,6 +2201,10 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
||||
s.EnableUploads = NewBool(false)
|
||||
}
|
||||
|
||||
if s.AllowInsecureDownloadUrl == nil {
|
||||
s.AllowInsecureDownloadUrl = NewBool(false)
|
||||
}
|
||||
|
||||
if s.Directory == nil {
|
||||
s.Directory = NewString(PLUGIN_SETTINGS_DEFAULT_DIRECTORY)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user