Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Add option to create HTTP check with IPV6 #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion pingdom/api_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type CheckResponse struct {
Teams []CheckTeamResponse `json:"teams,omitempty"`
ResponseTimeThreshold int `json:"responsetime_threshold,omitempty"`
ProbeFilters []string `json:"probe_filters,omitempty"`
IP6 bool `json:"ip6,omitempty"`
IPV6 bool `json:"ipv6,omitempty"`

// Legacy; this is not returned by the API, we backfill the value from the
// Teams field.
Expand Down
5 changes: 5 additions & 0 deletions pingdom/check_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type HttpCheck struct {
TeamIds []int `json:"teamids,omitempty"`
VerifyCertificate *bool `json:"verify_certificate,omitempty"`
SSLDownDaysBefore *int `json:"ssl_down_days_before,omitempty"`
IPV6 *bool `json:"ipv6,omitempty"`
}

// PingCheck represents a Pingdom ping check.
Expand Down Expand Up @@ -122,6 +123,10 @@ func (ck *HttpCheck) PutParams() map[string]string {
m["ssl_down_days_before"] = strconv.Itoa(*ck.SSLDownDaysBefore)
}

if ck.IPV6 != nil {
m["ipv6"] = strconv.FormatBool(*ck.IPV6)
}

// ShouldContain and ShouldNotContain are mutually exclusive.
// But we must define one so they can be emptied if required.
if ck.ShouldContain != "" {
Expand Down
6 changes: 6 additions & 0 deletions pingdom/check_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func TestHttpCheckPutParams(t *testing.T) {
verifyCertificate := true
ipv6 := true
sslDownDaysBefore := 10

tests := []struct {
Expand All @@ -33,6 +34,7 @@ func TestHttpCheckPutParams(t *testing.T) {
ResponseTimeThreshold: 2300,
VerifyCertificate: &verifyCertificate,
SSLDownDaysBefore: &sslDownDaysBefore,
IPV6: &ipv6,
},
wantParams: map[string]string{
"name": "fake check",
Expand All @@ -56,6 +58,7 @@ func TestHttpCheckPutParams(t *testing.T) {
"responsetime_threshold": "2300",
"verify_certificate": "true",
"ssl_down_days_before": "10",
"ipv6": "true",
},
},
{
Expand Down Expand Up @@ -109,6 +112,7 @@ func TestHttpCheckPutParams(t *testing.T) {

func TestHttpCheckPostParams(t *testing.T) {
verifyCertificate := true
ipv6 := true
sslDownDaysBefore := 10

check := HttpCheck{
Expand All @@ -127,6 +131,7 @@ func TestHttpCheckPostParams(t *testing.T) {
ResponseTimeThreshold: 2300,
VerifyCertificate: &verifyCertificate,
SSLDownDaysBefore: &sslDownDaysBefore,
IPV6: &ipv6,
}
want := map[string]string{
"name": "fake check",
Expand All @@ -147,6 +152,7 @@ func TestHttpCheckPostParams(t *testing.T) {
"responsetime_threshold": "2300",
"verify_certificate": "true",
"ssl_down_days_before": "10",
"ipv6": "true",
}

params := check.PostParams()
Expand Down