Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion api/v1alpha1/endpointmonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ type UptimeRobotConfig struct {
// Defines which http status codes are treated as up or down
// For ex: 200:0_401:1_503:1 (to accept 200 as down and 401 and 503 as up)
CustomHTTPStatuses string `json:"customHTTPStatuses,omitempty"`

// Defines custom http headers to sent to monitored url
// +optional
CustomHTTPHeaders []HttpHeader `json:"customHTTPHeaders,omitempty"`
}

// Represents a http header
type HttpHeader struct {
Name string `json:"name"`
Value string `json:"value"`
}

// UptimeConfig defines the configuration for Uptime Monitor Provider
Expand Down Expand Up @@ -317,7 +327,6 @@ type PingdomConfig struct {

// PingdomTransactionConfig defines the configuration for Pingdom Transaction Monitor Provider
type PingdomTransactionConfig struct {

// Check status: active or inactive
// +optional
Paused bool `json:"paused,omitempty"`
Expand Down
22 changes: 21 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ spec:
description: The uptimerobot alertContacts to be associated with
this monitor
type: string
customHTTPHeaders:
description: Defines custom http headers to sent to monitored
url
items:
description: Represents a http header
properties:
name:
type: string
value:
type: string
required:
- name
- value
type: object
type: array
customHTTPStatuses:
description: |-
Defines which http status codes are treated as up or down
Expand Down
12 changes: 12 additions & 0 deletions pkg/monitors/uptimerobot/uptime-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ func (monitor *UpTimeMonitorService) processProviderConfig(m models.Monitor, cre
body += "&custom_http_statuses=" + providerConfig.CustomHTTPStatuses
}

if providerConfig != nil && len(providerConfig.CustomHTTPHeaders) != 0 {
headers := map[string]string{}
for _, header := range providerConfig.CustomHTTPHeaders {
headers[header.Name] = header.Value
}
out, err := json.Marshal(headers)
if err != nil {
log.Error(err, "Unable to marshal headers to JSON")
}
body += "&custom_http_headers=" + url.PathEscape(string(out))
}

if providerConfig != nil && len(providerConfig.MonitorType) != 0 {
if strings.Contains(strings.ToLower(providerConfig.MonitorType), "http") {
body += "&type=1"
Expand Down