summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-03-07 13:53:07 -0600
committerGitHub <noreply@github.com>2018-03-07 13:53:07 -0600
commit03b6d1f652407fa9c3ec7e740e120a1c3e920de0 (patch)
treef6c65826fa497d51092c3115c93ec3dd44eaf6b6
parente8943936c51450540a4f2e8e7a2f3a2af90d14db (diff)
downloadchat-03b6d1f652407fa9c3ec7e740e120a1c3e920de0.tar.gz
chat-03b6d1f652407fa9c3ec7e740e120a1c3e920de0.tar.bz2
chat-03b6d1f652407fa9c3ec7e740e120a1c3e920de0.zip
respect plugin manifest webapp bundle_path (#8393)
-rw-r--r--model/manifest.go5
-rw-r--r--plugin/pluginenv/environment.go21
2 files changed, 22 insertions, 4 deletions
diff --git a/model/manifest.go b/model/manifest.go
index fdf69c2e6..32d4341cd 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -164,6 +164,11 @@ func (m *Manifest) ClientManifest() *Manifest {
cm.Name = ""
cm.Description = ""
cm.Backend = nil
+ if cm.Webapp != nil {
+ cm.Webapp = new(ManifestWebapp)
+ *cm.Webapp = *m.Webapp
+ cm.Webapp.BundlePath = "/static/" + m.Id + "_bundle.js"
+ }
return cm
}
diff --git a/plugin/pluginenv/environment.go b/plugin/pluginenv/environment.go
index f53021f74..adc9ddbde 100644
--- a/plugin/pluginenv/environment.go
+++ b/plugin/pluginenv/environment.go
@@ -8,6 +8,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
+ "path/filepath"
"sync"
"github.com/pkg/errors"
@@ -163,12 +164,24 @@ func (env *Environment) ActivatePlugin(id string) error {
return fmt.Errorf("env missing webapp path, cannot activate plugin: %v", id)
}
- webappBundle, err := ioutil.ReadFile(fmt.Sprintf("%s/%s/webapp/%s_bundle.js", env.searchPath, id, id))
+ bundlePath := filepath.Clean(bundle.Manifest.Webapp.BundlePath)
+ if bundlePath == "" || bundlePath[0] == '.' {
+ return fmt.Errorf("invalid webapp bundle path")
+ }
+ bundlePath = filepath.Join(env.searchPath, id, bundlePath)
+
+ webappBundle, err := ioutil.ReadFile(bundlePath)
if err != nil {
- if supervisor != nil {
- supervisor.Stop()
+ // Backwards compatibility for plugins where webapp.bundle_path was ignored. This should
+ // be removed eventually.
+ if webappBundle2, err2 := ioutil.ReadFile(fmt.Sprintf("%s/%s/webapp/%s_bundle.js", env.searchPath, id, id)); err2 == nil {
+ webappBundle = webappBundle2
+ } else {
+ if supervisor != nil {
+ supervisor.Stop()
+ }
+ return errors.Wrapf(err, "unable to read webapp bundle: %v", id)
}
- return errors.Wrapf(err, "unable to read webapp bundle: %v", id)
}
err = ioutil.WriteFile(fmt.Sprintf("%s/%s_bundle.js", env.webappPath, id), webappBundle, 0644)