|
|
|
@ -25,6 +25,12 @@ const (
|
|
|
|
|
repo = "jfa-go"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var buildTimeUnix string
|
|
|
|
|
var buildTime time.Time = func() time.Time {
|
|
|
|
|
i, _ := strconv.ParseInt(buildTimeUnix, 10, 64)
|
|
|
|
|
return time.Unix(i, 0)
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
type GHRelease struct {
|
|
|
|
|
HTMLURL string `json:"html_url"`
|
|
|
|
|
ID int `json:"id"`
|
|
|
|
@ -124,6 +130,7 @@ type Updater struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newUpdater(buildroneURL, namespace, repo, version, commit, buildType string) *Updater {
|
|
|
|
|
// fmt.Printf(`Updater intializing with "%s", "%s", "%s", "%s", "%s", "%s"\n`, buildroneURL, namespace, repo, version, commit, buildType)
|
|
|
|
|
bType := off
|
|
|
|
|
tag := ""
|
|
|
|
|
switch buildType {
|
|
|
|
@ -184,6 +191,7 @@ func (ud *Updater) GetTag() (Tag, int, error) {
|
|
|
|
|
return Tag{}, -1, nil
|
|
|
|
|
}
|
|
|
|
|
url := fmt.Sprintf("%s/repo/%s/%s/tag/latest/%s", ud.url, ud.namespace, ud.name, ud.tag)
|
|
|
|
|
// fmt.Printf("Pinging URL \"%s\" for updates\n", url)
|
|
|
|
|
req, _ := http.NewRequest("GET", url, nil)
|
|
|
|
|
resp, err := ud.httpClient.Do(req)
|
|
|
|
|
defer ud.timeoutHandler()
|
|
|
|
@ -205,7 +213,8 @@ func (ud *Updater) GetTag() (Tag, int, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *Tag) IsNew() bool {
|
|
|
|
|
return t.Version[:7] != commit && t.Ready
|
|
|
|
|
// fmt.Printf("Build Time: %+v, Release Date: %+v", buildTime, t.ReleaseDate)
|
|
|
|
|
return t.Version[:7] != commit && t.Ready && t.ReleaseDate.After(buildTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ud *Updater) getRelease() (release GHRelease, status int, err error) {
|
|
|
|
|