From ad4126032703502b0e5e809ab8492ab64a86bffa Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Tue, 22 Jan 2019 14:00:40 -0800 Subject: [PATCH] Clarify success-status config/option --- cmd/git-sync/main.go | 4 ++-- cmd/git-sync/webhook.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 8fd03f9..4ff79f7 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -67,7 +67,7 @@ var flWebhookURL = flag.String("webhook-url", envString("GIT_SYNC_WEBHOOK_URL", var flWebhookMethod = flag.String("webhook-method", envString("GIT_SYNC_WEBHOOK_METHOD", "POST"), "the method for the webook to send with") var flWebhookStatusSuccess = flag.Int("webhook-success-status", envInt("GIT_SYNC_WEBHOOK_SUCCESS_STATUS", 200), - "the status code which indicates a successful webhook call") + "the status code which indicates a successful webhook call. A value of -1 disables success checks to make webhooks fire-and-forget") var flWebhookTimeout = flag.Duration("webhook-timeout", envDuration("GIT_SYNC_WEBHOOK_TIMEOUT", time.Second), "the timeout used when communicating with the webhook target") var flWebhookBackoff = flag.Duration("webhook-backoff", envDuration("GIT_SYNC_WEBHOOK_BACKOFF", time.Second*3), @@ -217,7 +217,7 @@ func main() { webhook := Webhook{ URL: *flWebhookURL, Method: *flWebhookMethod, - Success: flWebhookStatusSuccess, + Success: *flWebhookStatusSuccess, Timeout: *flWebhookTimeout, Backoff: *flWebhookBackoff, } diff --git a/cmd/git-sync/webhook.go b/cmd/git-sync/webhook.go index 9f2bd7b..692db15 100644 --- a/cmd/git-sync/webhook.go +++ b/cmd/git-sync/webhook.go @@ -15,7 +15,7 @@ type Webhook struct { Method string // Code to look for when determining if the request was successful. // If this is not specified, request is sent and forgotten about. - Success *int + Success int // Timeout for the http/s request Timeout time.Duration // Backoff for failed webhook calls @@ -40,8 +40,8 @@ func (w *Webhook) Do() error { resp.Body.Close() // If the webhook has a success statusCode, check against it - if w.Success != nil && resp.StatusCode != *w.Success { - return fmt.Errorf("received response code %d expected %d", resp.StatusCode, *w.Success) + if w.Success != -1 && resp.StatusCode != w.Success { + return fmt.Errorf("received response code %d expected %d", resp.StatusCode, w.Success) } return nil