-
Notifications
You must be signed in to change notification settings - Fork 30
/
platforms.go
64 lines (58 loc) · 1.25 KB
/
platforms.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
package extensions
import jenkinsv1 "github.com/jenkins-x/jx-api/pkg/apis/jenkins.io/v1"
// Platform represents a platform for binaries
type Platform struct {
Goarch string
Goos string
}
var (
// DefaultPlatforms the default list of platforms to create plugins for
DefaultPlatforms = []Platform{
{
Goarch: "amd64",
Goos: "Windows",
},
{
Goarch: "amd64",
Goos: "Darwin",
},
{
Goarch: "amd64",
Goos: "Linux",
},
{
Goarch: "arm",
Goos: "Linux",
},
{
Goarch: "386",
Goos: "Linux",
},
}
)
// Extension returns the default distribution extension; `tar.gz` or `zip` for windows
func (p Platform) Extension() string {
if p.IsWindows() {
return "zip"
}
return "tar.gz"
}
// IsWindows returns true if the platform is windows
func (p Platform) IsWindows() bool {
return p.Goos == "Windows"
}
// CreateBinaries a helper function to create the binary resources for the platforms for a given callback
func CreateBinaries(createURLFn func(Platform) string) []jenkinsv1.Binary {
var answer []jenkinsv1.Binary
for _, p := range DefaultPlatforms {
u := createURLFn(p)
if u != "" {
answer = append(answer, jenkinsv1.Binary{
Goarch: p.Goarch,
Goos: p.Goos,
URL: u,
})
}
}
return answer
}