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
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
cbd3fa4b3b
Коммит
309a3dda60
@@ -585,18 +585,18 @@ func (a *App) trackPlugins() {
|
|||||||
}
|
}
|
||||||
if state, ok := pluginStates[plugin.Manifest.Id]; ok && state.Enable {
|
if state, ok := pluginStates[plugin.Manifest.Id]; ok && state.Enable {
|
||||||
totalEnabledCount += 1
|
totalEnabledCount += 1
|
||||||
if plugin.Manifest.Backend != nil {
|
if plugin.Manifest.HasServer() {
|
||||||
backendEnabledCount += 1
|
backendEnabledCount += 1
|
||||||
}
|
}
|
||||||
if plugin.Manifest.Webapp != nil {
|
if plugin.Manifest.HasWebapp() {
|
||||||
webappEnabledCount += 1
|
webappEnabledCount += 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
totalDisabledCount += 1
|
totalDisabledCount += 1
|
||||||
if plugin.Manifest.Backend != nil {
|
if plugin.Manifest.HasServer() {
|
||||||
backendDisabledCount += 1
|
backendDisabledCount += 1
|
||||||
}
|
}
|
||||||
if plugin.Manifest.Webapp != nil {
|
if plugin.Manifest.HasWebapp() {
|
||||||
webappDisabledCount += 1
|
webappDisabledCount += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ type PluginSettingsSchema struct {
|
|||||||
// id: com.mycompany.myplugin
|
// id: com.mycompany.myplugin
|
||||||
// name: My Plugin
|
// name: My Plugin
|
||||||
// description: This is my plugin. It does stuff.
|
// description: This is my plugin. It does stuff.
|
||||||
// backend:
|
// server:
|
||||||
// executable: myplugin
|
// executable: myplugin
|
||||||
// settings_schema:
|
// settings_schema:
|
||||||
// settings:
|
// settings:
|
||||||
@@ -108,8 +108,11 @@ type Manifest struct {
|
|||||||
// A version number for your plugin. Semantic versioning is recommended: http://semver.org
|
// A version number for your plugin. Semantic versioning is recommended: http://semver.org
|
||||||
Version string `json:"version" yaml:"version"`
|
Version string `json:"version" yaml:"version"`
|
||||||
|
|
||||||
// If your plugin extends the server, you'll need define backend.
|
// Server defines the server-side portion of your plugin.
|
||||||
Backend *ManifestBackend `json:"backend,omitempty" yaml:"backend,omitempty"`
|
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.
|
// If your plugin extends the web app, you'll need to define webapp.
|
||||||
Webapp *ManifestWebapp `json:"webapp,omitempty" yaml:"webapp,omitempty"`
|
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"`
|
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
|
// Executables are the paths to your executable binaries, specifying multiple entry points
|
||||||
// for different platforms when bundled together in a single plugin.
|
// for different platforms when bundled together in a single plugin.
|
||||||
Executables *ManifestExecutables `json:"executables,omitempty" yaml:"executables,omitempty"`
|
Executables *ManifestExecutables `json:"executables,omitempty" yaml:"executables,omitempty"`
|
||||||
@@ -181,7 +184,7 @@ func (m *Manifest) ClientManifest() *Manifest {
|
|||||||
*cm = *m
|
*cm = *m
|
||||||
cm.Name = ""
|
cm.Name = ""
|
||||||
cm.Description = ""
|
cm.Description = ""
|
||||||
cm.Backend = nil
|
cm.Server = nil
|
||||||
if cm.Webapp != nil {
|
if cm.Webapp != nil {
|
||||||
cm.Webapp = new(ManifestWebapp)
|
cm.Webapp = new(ManifestWebapp)
|
||||||
*cm.Webapp = *m.Webapp
|
*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
|
// is defined, the Executable field will be returned. This method does not guarantee that the
|
||||||
// resulting binary can actually execute on the given platform.
|
// resulting binary can actually execute on the given platform.
|
||||||
func (m *Manifest) GetExecutableForRuntime(goOs, goArch string) string {
|
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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var executable string
|
var executable string
|
||||||
if m.Backend.Executables != nil {
|
if server.Executables != nil {
|
||||||
if goOs == "linux" && goArch == "amd64" {
|
if goOs == "linux" && goArch == "amd64" {
|
||||||
executable = m.Backend.Executables.LinuxAmd64
|
executable = server.Executables.LinuxAmd64
|
||||||
} else if goOs == "darwin" && goArch == "amd64" {
|
} else if goOs == "darwin" && goArch == "amd64" {
|
||||||
executable = m.Backend.Executables.DarwinAmd64
|
executable = server.Executables.DarwinAmd64
|
||||||
} else if goOs == "windows" && goArch == "amd64" {
|
} else if goOs == "windows" && goArch == "amd64" {
|
||||||
executable = m.Backend.Executables.WindowsAmd64
|
executable = server.Executables.WindowsAmd64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if executable == "" {
|
if executable == "" {
|
||||||
executable = m.Backend.Executable
|
executable = server.Executable
|
||||||
}
|
}
|
||||||
|
|
||||||
return 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.
|
// 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
|
// In all cases other than a does-not-exist error, path is set to the path of the manifest file that was
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func TestFindManifest(t *testing.T) {
|
|||||||
func TestManifestUnmarshal(t *testing.T) {
|
func TestManifestUnmarshal(t *testing.T) {
|
||||||
expected := Manifest{
|
expected := Manifest{
|
||||||
Id: "theid",
|
Id: "theid",
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "theexecutable",
|
Executable: "theexecutable",
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "theexecutable-linux-amd64",
|
LinuxAmd64: "theexecutable-linux-amd64",
|
||||||
@@ -101,7 +101,7 @@ func TestManifestUnmarshal(t *testing.T) {
|
|||||||
var yamlResult Manifest
|
var yamlResult Manifest
|
||||||
require.NoError(t, yaml.Unmarshal([]byte(`
|
require.NoError(t, yaml.Unmarshal([]byte(`
|
||||||
id: theid
|
id: theid
|
||||||
backend:
|
server:
|
||||||
executable: theexecutable
|
executable: theexecutable
|
||||||
executables:
|
executables:
|
||||||
linux-amd64: theexecutable-linux-amd64
|
linux-amd64: theexecutable-linux-amd64
|
||||||
@@ -129,7 +129,7 @@ settings_schema:
|
|||||||
var jsonResult Manifest
|
var jsonResult Manifest
|
||||||
require.NoError(t, json.Unmarshal([]byte(`{
|
require.NoError(t, json.Unmarshal([]byte(`{
|
||||||
"id": "theid",
|
"id": "theid",
|
||||||
"backend": {
|
"server": {
|
||||||
"executable": "theexecutable",
|
"executable": "theexecutable",
|
||||||
"executables": {
|
"executables": {
|
||||||
"linux-amd64": "theexecutable-linux-amd64",
|
"linux-amd64": "theexecutable-linux-amd64",
|
||||||
@@ -185,7 +185,7 @@ func TestFindManifest_FileErrors(t *testing.T) {
|
|||||||
func TestManifestJson(t *testing.T) {
|
func TestManifestJson(t *testing.T) {
|
||||||
manifest := &Manifest{
|
manifest := &Manifest{
|
||||||
Id: "theid",
|
Id: "theid",
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "theexecutable",
|
Executable: "theexecutable",
|
||||||
},
|
},
|
||||||
Webapp: &ManifestWebapp{
|
Webapp: &ManifestWebapp{
|
||||||
@@ -230,7 +230,7 @@ func TestManifestJson(t *testing.T) {
|
|||||||
func TestManifestHasClient(t *testing.T) {
|
func TestManifestHasClient(t *testing.T) {
|
||||||
manifest := &Manifest{
|
manifest := &Manifest{
|
||||||
Id: "theid",
|
Id: "theid",
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "theexecutable",
|
Executable: "theexecutable",
|
||||||
},
|
},
|
||||||
Webapp: &ManifestWebapp{
|
Webapp: &ManifestWebapp{
|
||||||
@@ -250,7 +250,7 @@ func TestManifestClientManifest(t *testing.T) {
|
|||||||
Name: "thename",
|
Name: "thename",
|
||||||
Description: "thedescription",
|
Description: "thedescription",
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "theexecutable",
|
Executable: "theexecutable",
|
||||||
},
|
},
|
||||||
Webapp: &ManifestWebapp{
|
Webapp: &ManifestWebapp{
|
||||||
@@ -287,14 +287,14 @@ func TestManifestClientManifest(t *testing.T) {
|
|||||||
assert.NotEmpty(t, sanitized.SettingsSchema)
|
assert.NotEmpty(t, sanitized.SettingsSchema)
|
||||||
assert.Empty(t, sanitized.Name)
|
assert.Empty(t, sanitized.Name)
|
||||||
assert.Empty(t, sanitized.Description)
|
assert.Empty(t, sanitized.Description)
|
||||||
assert.Empty(t, sanitized.Backend)
|
assert.Empty(t, sanitized.Server)
|
||||||
|
|
||||||
assert.NotEmpty(t, manifest.Id)
|
assert.NotEmpty(t, manifest.Id)
|
||||||
assert.NotEmpty(t, manifest.Version)
|
assert.NotEmpty(t, manifest.Version)
|
||||||
assert.NotEmpty(t, manifest.Webapp)
|
assert.NotEmpty(t, manifest.Webapp)
|
||||||
assert.NotEmpty(t, manifest.Name)
|
assert.NotEmpty(t, manifest.Name)
|
||||||
assert.NotEmpty(t, manifest.Description)
|
assert.NotEmpty(t, manifest.Description)
|
||||||
assert.NotEmpty(t, manifest.Backend)
|
assert.NotEmpty(t, manifest.Server)
|
||||||
assert.NotEmpty(t, manifest.SettingsSchema)
|
assert.NotEmpty(t, manifest.SettingsSchema)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
ExpectedExecutable string
|
ExpectedExecutable string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"no backend",
|
"no server",
|
||||||
&Manifest{},
|
&Manifest{},
|
||||||
"linux",
|
"linux",
|
||||||
"amd64",
|
"amd64",
|
||||||
@@ -316,7 +316,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"no executable",
|
"no executable",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{},
|
Server: &ManifestServer{},
|
||||||
},
|
},
|
||||||
"linux",
|
"linux",
|
||||||
"amd64",
|
"amd64",
|
||||||
@@ -325,7 +325,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"single executable",
|
"single executable",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "path/to/executable",
|
Executable: "path/to/executable",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -336,7 +336,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"single executable, different runtime",
|
"single executable, different runtime",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "path/to/executable",
|
Executable: "path/to/executable",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -347,7 +347,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, no match",
|
"multiple executables, no match",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -362,7 +362,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, linux-amd64 match",
|
"multiple executables, linux-amd64 match",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -377,7 +377,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, linux-amd64 match, single executable ignored",
|
"multiple executables, linux-amd64 match, single executable ignored",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -393,7 +393,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, darwin-amd64 match",
|
"multiple executables, darwin-amd64 match",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -408,7 +408,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, windows-amd64 match",
|
"multiple executables, windows-amd64 match",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -423,7 +423,7 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"multiple executables, no match, single executable fallback",
|
"multiple executables, no match, single executable fallback",
|
||||||
&Manifest{
|
&Manifest{
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executables: &ManifestExecutables{
|
Executables: &ManifestExecutables{
|
||||||
LinuxAmd64: "linux-amd64/path/to/executable",
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
DarwinAmd64: "darwin-amd64/path/to/executable",
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
@@ -436,6 +436,43 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
"amd64",
|
"amd64",
|
||||||
"path/to/executable",
|
"path/to/executable",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"deprecated backend field, ignored since server present",
|
||||||
|
&Manifest{
|
||||||
|
Server: &ManifestServer{
|
||||||
|
Executables: &ManifestExecutables{
|
||||||
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
|
WindowsAmd64: "windows-amd64/path/to/executable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Backend: &ManifestServer{
|
||||||
|
Executables: &ManifestExecutables{
|
||||||
|
LinuxAmd64: "linux-amd64/path/to/executable/backend",
|
||||||
|
DarwinAmd64: "darwin-amd64/path/to/executable/backend",
|
||||||
|
WindowsAmd64: "windows-amd64/path/to/executable/backend",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"linux",
|
||||||
|
"amd64",
|
||||||
|
"linux-amd64/path/to/executable",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"deprecated backend field used, since no server present",
|
||||||
|
&Manifest{
|
||||||
|
Backend: &ManifestServer{
|
||||||
|
Executables: &ManifestExecutables{
|
||||||
|
LinuxAmd64: "linux-amd64/path/to/executable/backend",
|
||||||
|
DarwinAmd64: "darwin-amd64/path/to/executable/backend",
|
||||||
|
WindowsAmd64: "windows-amd64/path/to/executable/backend",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"linux",
|
||||||
|
"amd64",
|
||||||
|
"linux-amd64/path/to/executable/backend",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
@@ -448,3 +485,110 @@ func TestManifestGetExecutableForRuntime(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestManifestHasServer(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
Description string
|
||||||
|
Manifest *Manifest
|
||||||
|
Expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"no server",
|
||||||
|
&Manifest{},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"no executable, but server still considered present",
|
||||||
|
&Manifest{
|
||||||
|
Server: &ManifestServer{},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"single executable",
|
||||||
|
&Manifest{
|
||||||
|
Server: &ManifestServer{
|
||||||
|
Executable: "path/to/executable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple executables",
|
||||||
|
&Manifest{
|
||||||
|
Server: &ManifestServer{
|
||||||
|
Executables: &ManifestExecutables{
|
||||||
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
|
WindowsAmd64: "windows-amd64/path/to/executable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"single executable defined via deprecated backend",
|
||||||
|
&Manifest{
|
||||||
|
Backend: &ManifestServer{
|
||||||
|
Executable: "path/to/executable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"multiple executables defined via deprecated backend",
|
||||||
|
&Manifest{
|
||||||
|
Backend: &ManifestServer{
|
||||||
|
Executables: &ManifestExecutables{
|
||||||
|
LinuxAmd64: "linux-amd64/path/to/executable",
|
||||||
|
DarwinAmd64: "darwin-amd64/path/to/executable",
|
||||||
|
WindowsAmd64: "windows-amd64/path/to/executable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
|
assert.Equal(t, testCase.Expected, testCase.Manifest.HasServer())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestManifestHasWebapp(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
Description string
|
||||||
|
Manifest *Manifest
|
||||||
|
Expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"no webapp",
|
||||||
|
&Manifest{},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"no bundle path, but webapp still considered present",
|
||||||
|
&Manifest{
|
||||||
|
Webapp: &ManifestWebapp{},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bundle path defined",
|
||||||
|
&Manifest{
|
||||||
|
Webapp: &ManifestWebapp{
|
||||||
|
BundlePath: "path/to/bundle",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
|
assert.Equal(t, testCase.Expected, testCase.Manifest.HasWebapp())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
func TestPluginsResponseJson(t *testing.T) {
|
func TestPluginsResponseJson(t *testing.T) {
|
||||||
manifest := &Manifest{
|
manifest := &Manifest{
|
||||||
Id: "theid",
|
Id: "theid",
|
||||||
Backend: &ManifestBackend{
|
Server: &ManifestServer{
|
||||||
Executable: "theexecutable",
|
Executable: "theexecutable",
|
||||||
},
|
},
|
||||||
Webapp: &ManifestWebapp{
|
Webapp: &ManifestWebapp{
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ func (env *Environment) Activate(id string) (reterr error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if pluginInfo.Manifest.Backend != nil {
|
if pluginInfo.Manifest.HasServer() {
|
||||||
supervisor, err := newSupervisor(pluginInfo, env.logger, env.newAPIImpl(pluginInfo.Manifest))
|
supervisor, err := newSupervisor(pluginInfo, env.logger, env.newAPIImpl(pluginInfo.Manifest))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "unable to start plugin: %v", id)
|
return errors.Wrapf(err, "unable to start plugin: %v", id)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user