From e4596fbc9a51535adf80b93d05eda9a249ea129f Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:05:31 +0200 Subject: [PATCH 1/7] Add raw_post_data var to statuscake --- api/v1alpha1/endpointmonitor_types.go | 4 ++++ .../bases/endpointmonitor.stakater.com_endpointmonitors.yaml | 4 ++++ pkg/monitors/statuscake/statuscake-monitor.go | 3 +++ 3 files changed, 11 insertions(+) diff --git a/api/v1alpha1/endpointmonitor_types.go b/api/v1alpha1/endpointmonitor_types.go index c8a2f70b..1f82fa91 100644 --- a/api/v1alpha1/endpointmonitor_types.go +++ b/api/v1alpha1/endpointmonitor_types.go @@ -224,6 +224,10 @@ type StatusCakeConfig struct { // String to look for within the response. Considered down if not found // +optional FindString string `json:"findString,omitempty"` + + // RawPostData can be used to send parameters within the URL. Changes the request from a GET to a POST + // +optional + RawPostData string `json:"rawPostData,omitempty"` } // PingdomConfig defines the configuration for Pingdom Monitor Provider diff --git a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml index 0f984d44..6b988ef3 100644 --- a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -288,6 +288,10 @@ spec: port: description: TCP Port type: integer + rawPostData: + description: RawPostData can be used to send parameters within + the URL. Changes the request from a GET to a POST + type: string realBrowser: description: Enable Real Browser type: boolean diff --git a/pkg/monitors/statuscake/statuscake-monitor.go b/pkg/monitors/statuscake/statuscake-monitor.go index 0ed9b13e..9e6f5948 100644 --- a/pkg/monitors/statuscake/statuscake-monitor.go +++ b/pkg/monitors/statuscake/statuscake-monitor.go @@ -202,6 +202,9 @@ func buildUpsertForm(m models.Monitor, cgroup string) url.Values { if providerConfig != nil { f.Add("find_string", providerConfig.FindString) } + if providerConfig != nil && len(providerConfig.RawPostData) > 0 { + f.Add("post_raw", providerConfig.RawPostData) + } return f } From 30c9cbb2dc5b85e4e68db0565720608cdf92203a Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:16:52 +0200 Subject: [PATCH 2/7] Add user_agent var to statuscake --- api/v1alpha1/endpointmonitor_types.go | 4 ++++ pkg/monitors/statuscake/statuscake-monitor.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/api/v1alpha1/endpointmonitor_types.go b/api/v1alpha1/endpointmonitor_types.go index 1f82fa91..887c0340 100644 --- a/api/v1alpha1/endpointmonitor_types.go +++ b/api/v1alpha1/endpointmonitor_types.go @@ -228,6 +228,10 @@ type StatusCakeConfig struct { // RawPostData can be used to send parameters within the URL. Changes the request from a GET to a POST // +optional RawPostData string `json:"rawPostData,omitempty"` + + // UserAgent is used to set a user agent string. + // +optional + UserAgent string `json:"userAgent,omitempty"` } // PingdomConfig defines the configuration for Pingdom Monitor Provider diff --git a/pkg/monitors/statuscake/statuscake-monitor.go b/pkg/monitors/statuscake/statuscake-monitor.go index 9e6f5948..ffea6a9c 100644 --- a/pkg/monitors/statuscake/statuscake-monitor.go +++ b/pkg/monitors/statuscake/statuscake-monitor.go @@ -205,6 +205,9 @@ func buildUpsertForm(m models.Monitor, cgroup string) url.Values { if providerConfig != nil && len(providerConfig.RawPostData) > 0 { f.Add("post_raw", providerConfig.RawPostData) } + if providerConfig != nil && len(providerConfig.UserAgent) > 0 { + f.Add("user_agent", providerConfig.UserAgent) + } return f } From 91b5b8b4766faf6cbae696442217d20bff83dde6 Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:19:45 +0200 Subject: [PATCH 3/7] Update formatting for user_agent --- api/v1alpha1/endpointmonitor_types.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/endpointmonitor_types.go b/api/v1alpha1/endpointmonitor_types.go index 887c0340..ac0eebed 100644 --- a/api/v1alpha1/endpointmonitor_types.go +++ b/api/v1alpha1/endpointmonitor_types.go @@ -229,9 +229,9 @@ type StatusCakeConfig struct { // +optional RawPostData string `json:"rawPostData,omitempty"` - // UserAgent is used to set a user agent string. - // +optional - UserAgent string `json:"userAgent,omitempty"` + // UserAgent is used to set a user agent string. + // +optional + UserAgent string `json:"userAgent,omitempty"` } // PingdomConfig defines the configuration for Pingdom Monitor Provider From b4c2ecff0e41751650d9a6880239425a62391708 Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:24:26 +0200 Subject: [PATCH 4/7] Fix tabs in statuscake-monitor.go --- pkg/monitors/statuscake/statuscake-monitor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/monitors/statuscake/statuscake-monitor.go b/pkg/monitors/statuscake/statuscake-monitor.go index ffea6a9c..f6d52d4f 100644 --- a/pkg/monitors/statuscake/statuscake-monitor.go +++ b/pkg/monitors/statuscake/statuscake-monitor.go @@ -205,9 +205,9 @@ func buildUpsertForm(m models.Monitor, cgroup string) url.Values { if providerConfig != nil && len(providerConfig.RawPostData) > 0 { f.Add("post_raw", providerConfig.RawPostData) } - if providerConfig != nil && len(providerConfig.UserAgent) > 0 { - f.Add("user_agent", providerConfig.UserAgent) - } + if providerConfig != nil && len(providerConfig.UserAgent) > 0 { + f.Add("user_agent", providerConfig.UserAgent) + } return f } From 49046b85d630daca104c4216e146bfff3a31fced Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:31:04 +0200 Subject: [PATCH 5/7] Update base crds --- .../bases/endpointmonitor.stakater.com_endpointmonitors.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml index 6b988ef3..5de8cbcc 100644 --- a/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -311,6 +311,9 @@ spec: triggerRate: description: Minutes to wait before sending an alert type: integer + userAgent: + description: UserAgent is used to set a user agent string. + type: string type: object updownConfig: description: Configuration for Updown Monitor Provider From b64294afbd60d09205829884e2c797c5732ae454 Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Wed, 2 Oct 2024 14:37:57 +0200 Subject: [PATCH 6/7] Docs and example update --- docs/statuscake-configuration.md | 2 ++ examples/endpointMonitor/statuscake-config.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/statuscake-configuration.md b/docs/statuscake-configuration.md index bd0c62bf..75ac93d0 100644 --- a/docs/statuscake-configuration.md +++ b/docs/statuscake-configuration.md @@ -26,6 +26,8 @@ Currently additional Statuscake configurations can be added through these fields | FindString | String to look for within the response | | BasicAuthUser | Required for [basic-authenticationchecks](#basic-auth-checks) | | Regions | Regions to execute the check from | +| RawPostData | Add data to change the request to a POST | +| UserAgent | Add a user agent string to the request | ### Basic Auth checks diff --git a/examples/endpointMonitor/statuscake-config.yaml b/examples/endpointMonitor/statuscake-config.yaml index bf4f64eb..fd006504 100644 --- a/examples/endpointMonitor/statuscake-config.yaml +++ b/examples/endpointMonitor/statuscake-config.yaml @@ -20,4 +20,6 @@ spec: pingUrl: 'https://stakater2.com/' contactGroup: '123456,654321' regions: amsterdam, stockholm + rawPostData: '{"test": "data"}' + userAgent: test-user url: 'https://stakater1.com/' From 4a667f040b924025be39091ff44e88655d4bf466 Mon Sep 17 00:00:00 2001 From: Matthijs Wolters Date: Thu, 3 Oct 2024 17:05:39 +0200 Subject: [PATCH 7/7] Update CRDs --- .../endpointmonitor.stakater.com_endpointmonitors.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml b/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml index 0f984d44..5de8cbcc 100644 --- a/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml +++ b/charts/ingressmonitorcontroller/crds/endpointmonitor.stakater.com_endpointmonitors.yaml @@ -288,6 +288,10 @@ spec: port: description: TCP Port type: integer + rawPostData: + description: RawPostData can be used to send parameters within + the URL. Changes the request from a GET to a POST + type: string realBrowser: description: Enable Real Browser type: boolean @@ -307,6 +311,9 @@ spec: triggerRate: description: Minutes to wait before sending an alert type: integer + userAgent: + description: UserAgent is used to set a user agent string. + type: string type: object updownConfig: description: Configuration for Updown Monitor Provider