-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (39 loc) · 1.11 KB
/
main.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
package github
import (
"github.com/ironstar-io/ironstar-cli/internal/api"
)
// ReleaseBody - Used properties from the GH API GET call
type ReleaseBody struct {
TagName string `json:"tag_name"`
HTMLURL string `json:"html_url"`
Prerelease bool `json:"prerelease"`
Draft bool `json:"draft"`
Assets []struct {
Name string `json:"name"`
URL string `json:"browser_download_url"`
}
}
// GetRelease - Get an Ironstar CLI release
func GetRelease(version string) (*api.RawResponse, error) {
req := api.Request{
Method: "GET",
URL: "https://api.github.com/repos/ironstar-io/ironstar-cli/releases" + version,
MapStringPayload: map[string]interface{}{},
}
res, err := req.HTTPSend()
if err != nil {
return nil, err
}
if res.StatusCode != 200 {
return nil, res.HandleExternalFailure()
}
return res, nil
}
// GetLatestRelease - Get latest Ironstar CLI release
func GetLatestRelease() (*api.RawResponse, error) {
return GetRelease("/latest")
}
// GetAllReleases - Get all Ironstar CLI releases
func GetAllReleases() (*api.RawResponse, error) {
return GetRelease("")
}