summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-11-30 14:55:44 -0600
committerGitHub <noreply@github.com>2017-11-30 14:55:44 -0600
commitdaebd26a2894d88eb4c703b3be75f042cd563fef (patch)
tree0dfd6d21a1c284271f366c1b8279833fc4e7ed30 /model
parenteaca461ee35993c07936a5888c003153d9e9b24f (diff)
downloadchat-daebd26a2894d88eb4c703b3be75f042cd563fef.tar.gz
chat-daebd26a2894d88eb4c703b3be75f042cd563fef.tar.bz2
chat-daebd26a2894d88eb4c703b3be75f042cd563fef.zip
PLT-8018: Bundled jira plugin (#7920)
* bundled jira plugin * fix generated file formatting, add prepackaged key * whoops, uploaded wrong file * whitelist generated files for license check * make it work for people without go/bin in their path
Diffstat (limited to 'model')
-rw-r--r--model/manifest.go19
-rw-r--r--model/manifest_test.go68
-rw-r--r--model/plugins_response.go9
-rw-r--r--model/plugins_response_test.go4
4 files changed, 48 insertions, 52 deletions
diff --git a/model/manifest.go b/model/manifest.go
index 121d3e0d2..12f105aaa 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -31,9 +31,6 @@ type PluginOption struct {
}
type PluginSetting struct {
- // The key that the setting will be assigned to in the configuration file.
- Key string `json:"key" yaml:"key"`
-
// The display name for the setting.
DisplayName string `json:"display_name" yaml:"display_name"`
@@ -79,8 +76,8 @@ type PluginSettingsSchema struct {
// Optional text to display below the settings.
Footer string `json:"footer" yaml:"footer"`
- // A list of setting definitions.
- Settings []*PluginSetting `json:"settings" yaml:"settings"`
+ // A mapping of setting keys to schema definitions.
+ Settings map[string]*PluginSetting `json:"settings" yaml:"settings"`
}
// The plugin manifest defines the metadata required to load and present your plugin. The manifest
@@ -96,11 +93,11 @@ type PluginSettingsSchema struct {
// executable: myplugin
// settings_schema:
// settings:
-// - key: enable_extra_thing
-// type: bool
-// display_name: Enable Extra Thing
-// help_text: When true, an extra thing will be enabled!
-// default: false
+// enable_extra_thing:
+// type: bool
+// display_name: Enable Extra Thing
+// help_text: When true, an extra thing will be enabled!
+// default: false
type Manifest struct {
// The id is a globally unique identifier that represents your plugin. Reverse-DNS notation
// using a name you control is a good option. For example, "com.mycompany.myplugin".
@@ -129,8 +126,6 @@ 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.
- //
- // On Windows, this file must have a ".exe" extension.
Executable string `json:"executable" yaml:"executable"`
}
diff --git a/model/manifest_test.go b/model/manifest_test.go
index 3fdc13ec4..0edd1fed4 100644
--- a/model/manifest_test.go
+++ b/model/manifest_test.go
@@ -70,9 +70,8 @@ func TestManifestUnmarshal(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext",
Footer: "thefootertext",
- Settings: []*PluginSetting{
- &PluginSetting{
- Key: "thesetting",
+ Settings: map[string]*PluginSetting{
+ "thesetting": &PluginSetting{
DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext",
@@ -101,16 +100,16 @@ settings_schema:
header: theheadertext
footer: thefootertext
settings:
- - key: thesetting
- display_name: thedisplayname
- type: dropdown
- help_text: thehelptext
- regenerate_help_text: theregeneratehelptext
- placeholder: theplaceholder
- options:
- - display_name: theoptiondisplayname
- value: thevalue
- default: thedefault
+ thesetting:
+ display_name: thedisplayname
+ type: dropdown
+ help_text: thehelptext
+ regenerate_help_text: theregeneratehelptext
+ placeholder: theplaceholder
+ options:
+ - display_name: theoptiondisplayname
+ value: thevalue
+ default: thedefault
`), &yamlResult))
assert.Equal(t, expected, yamlResult)
@@ -126,23 +125,22 @@ settings_schema:
"settings_schema": {
"header": "theheadertext",
"footer": "thefootertext",
- "settings": [
- {
- "key": "thesetting",
- "display_name": "thedisplayname",
- "type": "dropdown",
- "help_text": "thehelptext",
- "regenerate_help_text": "theregeneratehelptext",
- "placeholder": "theplaceholder",
- "options": [
- {
- "display_name": "theoptiondisplayname",
- "value": "thevalue"
- }
- ],
- "default": "thedefault"
- }
- ]
+ "settings": {
+ "thesetting": {
+ "display_name": "thedisplayname",
+ "type": "dropdown",
+ "help_text": "thehelptext",
+ "regenerate_help_text": "theregeneratehelptext",
+ "placeholder": "theplaceholder",
+ "options": [
+ {
+ "display_name": "theoptiondisplayname",
+ "value": "thevalue"
+ }
+ ],
+ "default": "thedefault"
+ }
+ }
}
}`), &jsonResult))
assert.Equal(t, expected, jsonResult)
@@ -177,9 +175,8 @@ func TestManifestJson(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext",
Footer: "thefootertext",
- Settings: []*PluginSetting{
- &PluginSetting{
- Key: "thesetting",
+ Settings: map[string]*PluginSetting{
+ "thesetting": &PluginSetting{
DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext",
@@ -242,9 +239,8 @@ func TestManifestClientManifest(t *testing.T) {
SettingsSchema: &PluginSettingsSchema{
Header: "theheadertext",
Footer: "thefootertext",
- Settings: []*PluginSetting{
- &PluginSetting{
- Key: "thesetting",
+ Settings: map[string]*PluginSetting{
+ "thesetting": &PluginSetting{
DisplayName: "thedisplayname",
Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
HelpText: "thehelptext",
diff --git a/model/plugins_response.go b/model/plugins_response.go
index fc0bd79ea..74c89af26 100644
--- a/model/plugins_response.go
+++ b/model/plugins_response.go
@@ -8,9 +8,14 @@ import (
"io"
)
+type PluginInfo struct {
+ Manifest
+ Prepackaged bool `json:"prepackaged"`
+}
+
type PluginsResponse struct {
- Active []*Manifest `json:"active"`
- Inactive []*Manifest `json:"inactive"`
+ Active []*PluginInfo `json:"active"`
+ Inactive []*PluginInfo `json:"inactive"`
}
func (m *PluginsResponse) ToJson() string {
diff --git a/model/plugins_response_test.go b/model/plugins_response_test.go
index 9129c68f7..1aa3cbcd0 100644
--- a/model/plugins_response_test.go
+++ b/model/plugins_response_test.go
@@ -19,8 +19,8 @@ func TestPluginsResponseJson(t *testing.T) {
}
response := &PluginsResponse{
- Active: []*Manifest{manifest},
- Inactive: []*Manifest{},
+ Active: []*PluginInfo{{Manifest: *manifest}},
+ Inactive: []*PluginInfo{},
}
json := response.ToJson()