summaryrefslogtreecommitdiffstats
path: root/model/manifest.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-07-18 18:32:33 -0400
committerChristopher Speller <crspeller@gmail.com>2018-07-18 15:32:33 -0700
commit309a3dda605dbda6b9f6f769ea386764671ea5d3 (patch)
tree3b891fef93781aa8d4dcfe41d093715cb1be8913 /model/manifest.go
parentcbd3fa4b3ba0e24c6008ac1e501d7a7fe25c1c99 (diff)
downloadchat-309a3dda605dbda6b9f6f769ea386764671ea5d3.tar.gz
chat-309a3dda605dbda6b9f6f769ea386764671ea5d3.tar.bz2
chat-309a3dda605dbda6b9f6f769ea386764671ea5d3.zip
Support `server`, deprecate `backend` in plugin manifest (#9127)
* Support `server`, deprecate `backend` in plugin manifest This lets us converge on the use of the term `server` everywhere instead of sometimes `backend` and sometimes `server`. We're still using `webapp` and will eventually support `mobile` as well. The plan is actually to rip out these deprecations as part of releasing 5.2, but I want to coordinate the extra additional breakage at the same time, so for now this is a backwards compatible change. * fix failing tests
Diffstat (limited to 'model/manifest.go')
-rw-r--r--model/manifest.go40
1 files changed, 29 insertions, 11 deletions
diff --git a/model/manifest.go b/model/manifest.go
index 6a3b0bfad..e4ed6e4ef 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -84,7 +84,7 @@ type PluginSettingsSchema struct {
// id: com.mycompany.myplugin
// name: My Plugin
// description: This is my plugin. It does stuff.
-// backend:
+// server:
// executable: myplugin
// settings_schema:
// settings:
@@ -108,8 +108,11 @@ type Manifest struct {
// A version number for your plugin. Semantic versioning is recommended: http://semver.org
Version string `json:"version" yaml:"version"`
- // If your plugin extends the server, you'll need define backend.
- Backend *ManifestBackend `json:"backend,omitempty" yaml:"backend,omitempty"`
+ // Server defines the server-side portion of your plugin.
+ Server *ManifestServer `json:"server,omitempty" yaml:"server,omitempty"`
+
+ // Backend is a deprecated flag for defining the server-side portion of your plugin. Going forward, use Server instead.
+ Backend *ManifestServer `json:"backend,omitempty" yaml:"backend,omitempty"`
// If your plugin extends the web app, you'll need to define webapp.
Webapp *ManifestWebapp `json:"webapp,omitempty" yaml:"webapp,omitempty"`
@@ -119,7 +122,7 @@ type Manifest struct {
SettingsSchema *PluginSettingsSchema `json:"settings_schema,omitempty" yaml:"settings_schema,omitempty"`
}
-type ManifestBackend struct {
+type ManifestServer struct {
// Executables are the paths to your executable binaries, specifying multiple entry points
// for different platforms when bundled together in a single plugin.
Executables *ManifestExecutables `json:"executables,omitempty" yaml:"executables,omitempty"`
@@ -181,7 +184,7 @@ func (m *Manifest) ClientManifest() *Manifest {
*cm = *m
cm.Name = ""
cm.Description = ""
- cm.Backend = nil
+ cm.Server = nil
if cm.Webapp != nil {
cm.Webapp = new(ManifestWebapp)
*cm.Webapp = *m.Webapp
@@ -196,28 +199,43 @@ func (m *Manifest) ClientManifest() *Manifest {
// is defined, the Executable field will be returned. This method does not guarantee that the
// resulting binary can actually execute on the given platform.
func (m *Manifest) GetExecutableForRuntime(goOs, goArch string) string {
- if m.Backend == nil {
+ server := m.Server
+
+ // Support the deprecated backend parameter.
+ if server == nil {
+ server = m.Backend
+ }
+
+ if server == nil {
return ""
}
var executable string
- if m.Backend.Executables != nil {
+ if server.Executables != nil {
if goOs == "linux" && goArch == "amd64" {
- executable = m.Backend.Executables.LinuxAmd64
+ executable = server.Executables.LinuxAmd64
} else if goOs == "darwin" && goArch == "amd64" {
- executable = m.Backend.Executables.DarwinAmd64
+ executable = server.Executables.DarwinAmd64
} else if goOs == "windows" && goArch == "amd64" {
- executable = m.Backend.Executables.WindowsAmd64
+ executable = server.Executables.WindowsAmd64
}
}
if executable == "" {
- executable = m.Backend.Executable
+ executable = server.Executable
}
return executable
}
+func (m *Manifest) HasServer() bool {
+ return m.Server != nil || m.Backend != nil
+}
+
+func (m *Manifest) HasWebapp() bool {
+ return m.Webapp != nil
+}
+
// FindManifest will find and parse the manifest in a given directory.
//
// In all cases other than a does-not-exist error, path is set to the path of the manifest file that was