summaryrefslogtreecommitdiffstats
path: root/model/manifest.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-07-17 18:47:05 -0400
committerChristopher Speller <crspeller@gmail.com>2018-07-17 15:47:05 -0700
commite718d2544f6c719bc6e31f569400f44d54de3a34 (patch)
treebe01ad094f309d49092685b4ea377c2ed12904b0 /model/manifest.go
parentf2c180390599e66fee2f1a8c1a4ab52eea920c51 (diff)
downloadchat-e718d2544f6c719bc6e31f569400f44d54de3a34.tar.gz
chat-e718d2544f6c719bc6e31f569400f44d54de3a34.tar.bz2
chat-e718d2544f6c719bc6e31f569400f44d54de3a34.zip
MM-11366: support a plugin bundle with multiple executables (#9121)
This avoids the need to distribute multiple plugins per architecture.
Diffstat (limited to 'model/manifest.go')
-rw-r--r--model/manifest.go49
1 files changed, 47 insertions, 2 deletions
diff --git a/model/manifest.go b/model/manifest.go
index d494df466..6a3b0bfad 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -120,13 +120,30 @@ type Manifest struct {
}
type ManifestBackend struct {
- // The path to your executable binary. This should be relative to the root of your bundle and the
- // location of the manifest file.
+ // 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"`
+
+ // Executable is the path to your executable binary. This should be relative to the root
+ // of your bundle and the location of the manifest file.
//
// On Windows, this file must have a ".exe" extension.
+ //
+ // If your plugin is compiled for multiple platforms, consider bundling them together
+ // and using the Executables field instead.
Executable string `json:"executable" yaml:"executable"`
}
+type ManifestExecutables struct {
+ // LinuxAmd64 is the path to your executable binary for the corresponding platform
+ LinuxAmd64 string `json:"linux-amd64,omitempty" yaml:"linux-amd64,omitempty"`
+ // DarwinAmd64 is the path to your executable binary for the corresponding platform
+ DarwinAmd64 string `json:"darwin-amd64,omitempty" yaml:"darwin-amd64,omitempty"`
+ // WindowsAmd64 is the path to your executable binary for the corresponding platform
+ // This file must have a ".exe" extension
+ WindowsAmd64 string `json:"windows-amd64,omitempty" yaml:"windows-amd64,omitempty"`
+}
+
type ManifestWebapp struct {
// The path to your webapp bundle. This should be relative to the root of your bundle and the
// location of the manifest file.
@@ -173,6 +190,34 @@ func (m *Manifest) ClientManifest() *Manifest {
return cm
}
+// GetExecutableForRuntime returns the path to the executable for the given runtime architecture.
+//
+// If the manifest defines multiple executables, but none match, or if only a single executable
+// 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 {
+ return ""
+ }
+
+ var executable string
+ if m.Backend.Executables != nil {
+ if goOs == "linux" && goArch == "amd64" {
+ executable = m.Backend.Executables.LinuxAmd64
+ } else if goOs == "darwin" && goArch == "amd64" {
+ executable = m.Backend.Executables.DarwinAmd64
+ } else if goOs == "windows" && goArch == "amd64" {
+ executable = m.Backend.Executables.WindowsAmd64
+ }
+ }
+
+ if executable == "" {
+ executable = m.Backend.Executable
+ }
+
+ return executable
+}
+
// 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