diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 90c6474fee..2d90ff4fea 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -2039,7 +2039,7 @@ ], "properties": { "comparator": { - "description": "Comparator compares the event data with a user given value. Can be \"\u003e=\", \"\u003e\", \"=\", \"\u003c\", or \"\u003c=\". Is optional, and if left blank treated as equality \"=\".", + "description": "Comparator compares the event data with a user given value. Can be \"\u003e=\", \"\u003e\", \"=\", \"!=\", \"\u003c\", or \"\u003c=\". Is optional, and if left blank treated as equality \"=\".", "type": "string" }, "path": { diff --git a/api/sensor.html b/api/sensor.html index 2eb4a24ff3..ac392ce2b2 100644 --- a/api/sensor.html +++ b/api/sensor.html @@ -519,7 +519,7 @@
Comparator compares the event data with a user given value. -Can be “>=”, “>”, “=”, “<”, or “<=”. +Can be “>=”, “>”, “=”, “!=”, “<”, or “<=”. Is optional, and if left blank treated as equality “=”.
Comparator compares the event data with a user given value. Can be -“\>=”, “\>”, “=”, “\<”, or “\<=”. Is optional, and if left blank -treated as equality “=”. +“\>=”, “\>”, “=”, “\!=”, “\<”, or “\<=”. Is optional, and if left +blank treated as equality “=”.
diff --git a/docs/webhook-health-check.md b/docs/webhook-health-check.md new file mode 100644 index 0000000000..72ef52cdb1 --- /dev/null +++ b/docs/webhook-health-check.md @@ -0,0 +1,33 @@ +# Webhook Health Check + +![alpha](assets/alpha.svg) + +> v1.0 and after + +For `webhook` or `webhook` extended event sources such as `github`, `gitlab`, +`sns`, `slack`, `Storage GRID` and `stripe`, besides the endpint configured in +the spec, an endpoint `:${port}/health` will be created by default, this is +useful for LB or Ingress configuration for the event source, where usually a +health check endpoint is required. + +For example, besides `:12000/example1` and `:13000/example2`, the EventSource +object below also creates 2 extra endpoints, `:12000/health` and +`:13000/health`. A HTTP GET request to the health endpoint returns a text `OK` +with HTTP response code `200`. + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: EventSource +metadata: + name: webhook +spec: + webhook: + example: + port: "12000" + endpoint: /example1 + method: POST + example-foo: + port: "13000" + endpoint: /example2 + method: POST +``` diff --git a/eventsources/common/webhook/webhook.go b/eventsources/common/webhook/webhook.go index 0c99eb56a1..c0fc0b3929 100644 --- a/eventsources/common/webhook/webhook.go +++ b/eventsources/common/webhook/webhook.go @@ -24,6 +24,7 @@ import ( "github.com/gorilla/mux" "go.uber.org/zap" + "github.com/argoproj/argo-events/common" "github.com/argoproj/argo-events/common/logging" "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" ) @@ -99,14 +100,22 @@ func startServer(router Router, controller *Controller) { handler := controller.ActiveServerHandlers[route.Context.Port] routeName := route.Context.Port + route.Context.Endpoint - r := handler.GetRoute(routeName) if r == nil { r = handler.NewRoute().Name(routeName) r = r.Path(route.Context.Endpoint) + r.HandlerFunc(router.HandleRoute) } - r.HandlerFunc(router.HandleRoute) + healthCheckRouteName := route.Context.Port + "/health" + healthCheckRoute := handler.GetRoute(healthCheckRouteName) + if healthCheckRoute == nil { + healthCheckRoute = handler.NewRoute().Name(healthCheckRouteName) + healthCheckRoute = healthCheckRoute.Path("/health") + healthCheckRoute.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { + common.SendSuccessResponse(writer, "OK") + }) + } Lock.Unlock() } diff --git a/pkg/apis/sensor/v1alpha1/generated.proto b/pkg/apis/sensor/v1alpha1/generated.proto index 42ed0ae29a..ef3bba87fb 100644 --- a/pkg/apis/sensor/v1alpha1/generated.proto +++ b/pkg/apis/sensor/v1alpha1/generated.proto @@ -141,7 +141,7 @@ message DataFilter { repeated string value = 3; // Comparator compares the event data with a user given value. - // Can be ">=", ">", "=", "<", or "<=". + // Can be ">=", ">", "=", "!=", "<", or "<=". // Is optional, and if left blank treated as equality "=". optional string comparator = 4; } diff --git a/pkg/apis/sensor/v1alpha1/openapi_generated.go b/pkg/apis/sensor/v1alpha1/openapi_generated.go index be4778c512..fc5db69ddd 100644 --- a/pkg/apis/sensor/v1alpha1/openapi_generated.go +++ b/pkg/apis/sensor/v1alpha1/openapi_generated.go @@ -400,7 +400,7 @@ func schema_pkg_apis_sensor_v1alpha1_DataFilter(ref common.ReferenceCallback) co }, "comparator": { SchemaProps: spec.SchemaProps{ - Description: "Comparator compares the event data with a user given value. Can be \">=\", \">\", \"=\", \"<\", or \"<=\". Is optional, and if left blank treated as equality \"=\".", + Description: "Comparator compares the event data with a user given value. Can be \">=\", \">\", \"=\", \"!=\", \"<\", or \"<=\". Is optional, and if left blank treated as equality \"=\".", Type: []string{"string"}, Format: "", },