Make --webhook-success-status=0 the same as -1
This commit is contained in:
parent
20ed7df894
commit
e84a4cb4fd
|
|
@ -343,7 +343,7 @@ OPTIONS
|
||||||
|
|
||||||
--webhook-success-status <int>, $GIT_SYNC_WEBHOOK_SUCCESS_STATUS
|
--webhook-success-status <int>, $GIT_SYNC_WEBHOOK_SUCCESS_STATUS
|
||||||
The HTTP status code indicating a successful --webhook-url. Setting
|
The HTTP status code indicating a successful --webhook-url. Setting
|
||||||
this to -1 disables success checks to make webhooks
|
this to 0 disables success checks, which makes webhooks
|
||||||
"fire-and-forget". If not specified, this defaults to 200.
|
"fire-and-forget". If not specified, this defaults to 200.
|
||||||
|
|
||||||
--webhook-timeout <duration>, $GIT_SYNC_WEBHOOK_TIMEOUT
|
--webhook-timeout <duration>, $GIT_SYNC_WEBHOOK_TIMEOUT
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ var flWebhookURL = pflag.String("webhook-url", envString("GIT_SYNC_WEBHOOK_URL",
|
||||||
var flWebhookMethod = pflag.String("webhook-method", envString("GIT_SYNC_WEBHOOK_METHOD", "POST"),
|
var flWebhookMethod = pflag.String("webhook-method", envString("GIT_SYNC_WEBHOOK_METHOD", "POST"),
|
||||||
"the HTTP method for the webhook")
|
"the HTTP method for the webhook")
|
||||||
var flWebhookStatusSuccess = pflag.Int("webhook-success-status", envInt("GIT_SYNC_WEBHOOK_SUCCESS_STATUS", 200),
|
var flWebhookStatusSuccess = pflag.Int("webhook-success-status", envInt("GIT_SYNC_WEBHOOK_SUCCESS_STATUS", 200),
|
||||||
"the HTTP status code indicating a successful webhook (-1 disables success checks")
|
"the HTTP status code indicating a successful webhook (0 disables success checks")
|
||||||
var flWebhookTimeout = pflag.Duration("webhook-timeout", envDuration("GIT_SYNC_WEBHOOK_TIMEOUT", time.Second),
|
var flWebhookTimeout = pflag.Duration("webhook-timeout", envDuration("GIT_SYNC_WEBHOOK_TIMEOUT", time.Second),
|
||||||
"the timeout for the webhook")
|
"the timeout for the webhook")
|
||||||
var flWebhookBackoff = pflag.Duration("webhook-backoff", envDuration("GIT_SYNC_WEBHOOK_BACKOFF", time.Second*3),
|
var flWebhookBackoff = pflag.Duration("webhook-backoff", envDuration("GIT_SYNC_WEBHOOK_BACKOFF", time.Second*3),
|
||||||
|
|
@ -509,8 +509,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flWebhookURL != "" {
|
if *flWebhookURL != "" {
|
||||||
if *flWebhookStatusSuccess < -1 {
|
if *flWebhookStatusSuccess == -1 {
|
||||||
handleConfigError(log, true, "ERROR: --webhook-success-status must be a valid HTTP code or -1")
|
// Back-compat: -1 and 0 mean the same things
|
||||||
|
*flWebhookStatusSuccess = 0
|
||||||
|
}
|
||||||
|
if *flWebhookStatusSuccess < 0 {
|
||||||
|
handleConfigError(log, true, "ERROR: --webhook-success-status must be a valid HTTP code or 0")
|
||||||
}
|
}
|
||||||
if *flWebhookTimeout < time.Second {
|
if *flWebhookTimeout < time.Second {
|
||||||
handleConfigError(log, true, "ERROR: --webhook-timeout must be at least 1s")
|
handleConfigError(log, true, "ERROR: --webhook-timeout must be at least 1s")
|
||||||
|
|
@ -2205,7 +2209,7 @@ OPTIONS
|
||||||
|
|
||||||
--webhook-success-status <int>, $GIT_SYNC_WEBHOOK_SUCCESS_STATUS
|
--webhook-success-status <int>, $GIT_SYNC_WEBHOOK_SUCCESS_STATUS
|
||||||
The HTTP status code indicating a successful --webhook-url. Setting
|
The HTTP status code indicating a successful --webhook-url. Setting
|
||||||
this to -1 disables success checks to make webhooks
|
this to 0 disables success checks, which makes webhooks
|
||||||
"fire-and-forget". If not specified, this defaults to 200.
|
"fire-and-forget". If not specified, this defaults to 200.
|
||||||
|
|
||||||
--webhook-timeout <duration>, $GIT_SYNC_WEBHOOK_TIMEOUT
|
--webhook-timeout <duration>, $GIT_SYNC_WEBHOOK_TIMEOUT
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ func (w *Webhook) Do(ctx context.Context, hash string) error {
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
// If the webhook has a success statusCode, check against it
|
// If the webhook has a success statusCode, check against it
|
||||||
if w.success != -1 && resp.StatusCode != w.success {
|
if w.success > 0 && resp.StatusCode != w.success {
|
||||||
return fmt.Errorf("received response code %d expected %d", resp.StatusCode, w.success)
|
return fmt.Errorf("received response code %d expected %d", resp.StatusCode, w.success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1865,7 +1865,7 @@ function e2e::webhook_fire_and_forget() {
|
||||||
--repo="file://$REPO" \
|
--repo="file://$REPO" \
|
||||||
--root="$ROOT" \
|
--root="$ROOT" \
|
||||||
--webhook-url="http://$IP" \
|
--webhook-url="http://$IP" \
|
||||||
--webhook-success-status=-1 \
|
--webhook-success-status=0 \
|
||||||
--link="link" \
|
--link="link" \
|
||||||
>> "$1" 2>&1 &
|
>> "$1" 2>&1 &
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue