Merge branch 'k8s' of https://github.com/TwinProduction/gatus into add-auto-discovery
This commit is contained in:
commit
c746579222
@ -2,6 +2,9 @@ package provider
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TwinProduction/gatus/alerting/provider/custom"
|
"github.com/TwinProduction/gatus/alerting/provider/custom"
|
||||||
|
"github.com/TwinProduction/gatus/alerting/provider/pagerduty"
|
||||||
|
"github.com/TwinProduction/gatus/alerting/provider/slack"
|
||||||
|
"github.com/TwinProduction/gatus/alerting/provider/twilio"
|
||||||
"github.com/TwinProduction/gatus/core"
|
"github.com/TwinProduction/gatus/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,3 +16,11 @@ type AlertProvider interface {
|
|||||||
// ToCustomAlertProvider converts the provider into a custom.AlertProvider
|
// ToCustomAlertProvider converts the provider into a custom.AlertProvider
|
||||||
ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider
|
ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Validate interface implementation on compile
|
||||||
|
_ AlertProvider = (*custom.AlertProvider)(nil)
|
||||||
|
_ AlertProvider = (*twilio.AlertProvider)(nil)
|
||||||
|
_ AlertProvider = (*slack.AlertProvider)(nil)
|
||||||
|
_ AlertProvider = (*pagerduty.AlertProvider)(nil)
|
||||||
|
)
|
||||||
|
@ -19,6 +19,8 @@ func GetHTTPClient(insecure bool) *http.Client {
|
|||||||
insecureHTTPClient = &http.Client{
|
insecureHTTPClient = &http.Client{
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 10,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
MaxIdleConnsPerHost: 20,
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
@ -30,6 +32,10 @@ func GetHTTPClient(insecure bool) *http.Client {
|
|||||||
if secureHTTPClient == nil {
|
if secureHTTPClient == nil {
|
||||||
secureHTTPClient = &http.Client{
|
secureHTTPClient = &http.Client{
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 10,
|
||||||
|
Transport: &http.Transport{
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
MaxIdleConnsPerHost: 20,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return secureHTTPClient
|
return secureHTTPClient
|
||||||
|
@ -155,7 +155,11 @@ func sanitizeAndResolve(list []string, result *Result) []string {
|
|||||||
if err.Error() != "unexpected end of JSON input" {
|
if err.Error() != "unexpected end of JSON input" {
|
||||||
result.Errors = append(result.Errors, err.Error())
|
result.Errors = append(result.Errors, err.Error())
|
||||||
}
|
}
|
||||||
element = fmt.Sprintf("%s %s", element, InvalidConditionElementSuffix)
|
if wantLength {
|
||||||
|
element = fmt.Sprintf("len(%s) %s", element, InvalidConditionElementSuffix)
|
||||||
|
} else {
|
||||||
|
element = fmt.Sprintf("%s %s", element, InvalidConditionElementSuffix)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if wantLength {
|
if wantLength {
|
||||||
element = fmt.Sprintf("%d", resolvedElementLength)
|
element = fmt.Sprintf("%d", resolvedElementLength)
|
||||||
|
@ -126,6 +126,19 @@ func TestCondition_evaluateWithInvalidBodyJSONPathComplex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithInvalidBodyJSONPathComplexWithLengthFunction(t *testing.T) {
|
||||||
|
expectedResolvedCondition := "len([BODY].data.name) (INVALID) == john"
|
||||||
|
condition := Condition("len([BODY].data.name) == john")
|
||||||
|
result := &Result{Body: []byte("{\"data\": {\"id\": 1}}")}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a failure, because the path was invalid", condition)
|
||||||
|
}
|
||||||
|
if result.ConditionResults[0].Condition != expectedResolvedCondition {
|
||||||
|
t.Errorf("Condition '%s' should have resolved to '%s', but resolved to '%s' instead", condition, expectedResolvedCondition, result.ConditionResults[0].Condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCondition_evaluateWithBodyJSONPathDoublePlaceholders(t *testing.T) {
|
func TestCondition_evaluateWithBodyJSONPathDoublePlaceholders(t *testing.T) {
|
||||||
condition := Condition("[BODY].user.firstName != [BODY].user.lastName")
|
condition := Condition("[BODY].user.firstName != [BODY].user.lastName")
|
||||||
result := &Result{Body: []byte("{\"user\": {\"firstName\": \"john\", \"lastName\": \"doe\"}}")}
|
result := &Result{Body: []byte("{\"user\": {\"firstName\": \"john\", \"lastName\": \"doe\"}}")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user