10 ErrMissingName = errors.New("Missing or empty name field")
11 ErrMissingDesc = errors.New("Missing or empty description field")
12 ErrMissingSite = errors.New("Missing or empty website field")
15 // PluginInfo contains all the needed info about a plugin
16 // The info is just strings and are not used beyond that (except
17 // the Site and Install fields should be valid URLs). This means
18 // that the requirements for example can be formatted however the
19 // plugin maker decides, the fields will only be parsed by humans
20 // Name: name of plugin
21 // Desc: description of plugin
22 // Site: home website of plugin
23 // Install: install link for plugin (can be link to repo or zip file)
25 // Require: list of dependencies and requirements
26 type PluginInfo struct {
27 Name string `json:"Name"`
28 Desc string `json:"Description"`
29 Site string `json:"Website"`
32 // NewPluginInfo parses a JSON input into a valid PluginInfo struct
33 // Returns an error if there are any missing fields or any invalid fields
34 // There are no optional fields in a plugin info json file
35 func NewPluginInfo(data []byte) (*PluginInfo, error) {
38 dec := json.NewDecoder(bytes.NewReader(data))
39 // dec.DisallowUnknownFields() // Force errors
41 if err := dec.Decode(&info); err != nil {