integrate rollbar into herald

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-02-16 07:51:08 -05:00
parent 17886c3ec6
commit 89f22faac8
4 changed files with 30 additions and 5 deletions
Generated
+7 -1
View File
@@ -128,6 +128,12 @@
packages = ["."]
revision = "a61a99592b77c9ba629d254a693acffaeb4b7e28"
[[projects]]
name = "github.com/stvp/rollbar"
packages = ["."]
revision = "b20261800d8cda3be14dcef0d1a8320779bba61a"
version = "v0.5.1"
[[projects]]
name = "github.com/ulikunitz/xz"
packages = [
@@ -180,6 +186,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "c52cf21009f65e59e23de87241a797c6c48d7e018aafc1f37edf1f9403ba9387"
inputs-digest = "66f216da55122e2bdeccb44d15182200ff48bee768ba3ab20b617c7a06af102d"
solver-name = "gps-cdcl"
solver-version = 1
+4
View File
@@ -33,3 +33,7 @@
[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"
[[constraint]]
name = "github.com/stvp/rollbar"
version = "0.5.1"
+17 -2
View File
@@ -7,6 +7,7 @@ import (
"github.com/garyburd/redigo/redis"
"github.com/google/go-github/github"
"github.com/heroku/herald"
"github.com/stvp/rollbar"
"golang.org/x/oauth2"
"log"
"os"
@@ -15,6 +16,7 @@ import (
// GithubToken is Personal GitHub token. TODO: Create a bot account.
var GithubToken = os.Getenv("GITHUB_TOKEN")
var RollbarToken = os.Getenv("ROLLBAR_ACCESS_TOKEN")
// Opens an issue on GitHub for the given buildpack and new target.
//
@@ -57,6 +59,10 @@ func main() {
// Redis stuff.
Redis := herald.NewRedis("")
// Rollbar stuff.
rollbar.Token = RollbarToken
rollbar.Environment = "production"
// Color Stuff.
color.NoColor = false
@@ -96,7 +102,10 @@ func main() {
exe.EnsureExecutable()
// Execute the executable, print the results.
results := exe.Execute()
results, err := exe.Execute()
if err != nil {
rollbar.Error(rollbar.ERR, err)
}
for _, result := range results {
key := fmt.Sprintf("%s:%s:%s", bp, exe, result)
@@ -104,6 +113,9 @@ func main() {
// Store the results in Redis.
result, err := Redis.Connection.Do("SETNX", key, value)
if err != nil {
rollbar.Error(rollbar.ERR, err)
}
// The insert was successful (e.g. it didn't exist already)
if result.(int64) != int64(0) {
@@ -116,7 +128,9 @@ func main() {
if !success {
// If writing out the issue was unsuccessful, delete the key from Redis.
_, err := Redis.Connection.Do("DEL", key)
_ = err
if err != nil {
rollbar.Error(rollbar.ERR, err)
}
}
} else {
fmt.Println("New target, skipping GitHub notifications.")
@@ -125,6 +139,7 @@ func main() {
}
if err != nil {
rollbar.Error(rollbar.ERR, err)
log.Fatal(err)
}
+2 -2
View File
@@ -148,13 +148,13 @@ func (e Executable) EnsureExecutable() {
}
// Execute Executes the given executable, and returns results.
func (e Executable) Execute() []string {
func (e Executable) Execute() ([]string, error) {
out, err := exec.Command(e.Path).Output()
if err != nil {
// TODO: Update this to return, etc.
log.Fatal(err)
}
return strings.Split(strings.Trim(string(out), "\n"), "\n")
return strings.Split(strings.Trim(string(out), "\n"), "\n"), err
}