removing DEBUG env for now

This commit is contained in:
jackspirou 2015-11-21 10:47:06 -06:00
parent 2c97549581
commit fdef8d879d

23
main.go
View File

@ -16,8 +16,6 @@ import (
func main() { func main() {
fmt.Println(os.Getenv("DEBUG"))
// plugin settings // plugin settings
var repo = drone.Repo{} var repo = drone.Repo{}
var build = drone.Build{} var build = drone.Build{}
@ -114,8 +112,10 @@ func main() {
} }
defer resp.Body.Close() defer resp.Body.Close()
if vargs.Debug || os.Getenv("DEBUG") == "true" { // if debug is on or response status code is bad
if vargs.Debug || resp.StatusCode >= http.StatusBadRequest {
// read the response body
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
// I do not think we need to os.Exit(1) if we are // I do not think we need to os.Exit(1) if we are
@ -123,19 +123,12 @@ func main() {
fmt.Printf("Error reading http response body. %s\n", err) fmt.Printf("Error reading http response body. %s\n", err)
} }
// debug print // debug/info print
fmt.Printf("[debug] Webhook %d\n URL: %s\n METHOD: %s\n HEADERS: %s\n REQUEST BODY: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, req.Method, req.Header, string(b), resp.Status, string(body)) if vargs.Debug {
fmt.Printf("[debug] Webhook %d\n URL: %s\n METHOD: %s\n HEADERS: %s\n REQUEST BODY: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, req.Method, req.Header, string(b), resp.Status, string(body))
} else if resp.StatusCode >= http.StatusBadRequest { } else {
fmt.Printf("[info] Webhook %d\n URL: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, resp.Status, string(body))
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// I do not think we need to os.Exit(1) if we are
// unable to read a http response body.
fmt.Printf("Error reading http response body. %s\n", err)
} }
fmt.Printf("[info] Webhook %d\n URL: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, resp.Status, string(body))
} }
} }
} }