-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
67 lines (57 loc) 路 1.66 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package types
import (
"sort"
"strings"
)
type Toolbox struct {
Tools map[string]*Tool `yaml:"tools,omitempty"`
Target string `yaml:"target,omitempty"`
Upx bool `yaml:"upx,omitempty"`
CreateTarget *bool `yaml:"createTarget,omitempty"`
Aliases *map[string][]string `yaml:"aliases,omitempty"`
ExcludedSuffixes []string `yaml:"excludedSuffixes,omitempty"`
}
func (t *Toolbox) GetTools() []*Tool {
var tools []*Tool
for n := range t.Tools {
tool := t.Tools[n]
if tool.Github != "" || tool.DownloadURL != "" || tool.Google != "" {
if tool.Name == "" {
tool.Name = n
}
tools = append(tools, tool)
}
}
sort.Slice(tools, func(i, j int) bool {
return strings.ToLower(tools[i].Name) < strings.ToLower(tools[j].Name)
})
return tools
}
func (t *Toolbox) Versions() *Versions {
v := &Versions{Versions: map[string]string{}}
tools := t.GetTools()
for i := range tools {
t := tools[i]
if !t.CouldNotBeFound {
v.Versions[t.Name] = t.Version
}
}
return v
}
type Tool struct {
Name string `yaml:"name,omitempty"`
Github string `yaml:"github,omitempty"`
Google string `yaml:"google,omitempty"`
DownloadURL string `yaml:"downloadURL,omitempty"`
Version string `yaml:"version,omitempty"`
Additional []string `yaml:"additional,omitempty"`
Check string `yaml:"check,omitempty"`
CouldNotBeFound bool `yaml:"-"`
}
type ToolVersion struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
}
type Versions struct {
Versions map[string]string `yaml:"versions"`
}