Skip to content

Commit

Permalink
Merge branch 'use-nord-cloud-base'
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Sep 21, 2021
2 parents 6d33f76 + accabcb commit 78e16da
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 62 deletions.
64 changes: 22 additions & 42 deletions pingdom/resource_pingdom_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/nordcloud/go-pingdom/pingdom"
)

Expand All @@ -27,166 +28,145 @@ func resourcePingdomCheck() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: false,
},
"host": {
Type: schema.TypeString,
Required: true,
ForceNew: false,
},
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"http", "tcp", "ping"}, false),
},
"paused": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
Computed: true,
Default: false,
},
"responsetime_threshold": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
},
"resolution": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Default: 5,
ValidateFunc: validation.IntInSlice([]int{1, 5, 15, 30, 60}),
},
"sendnotificationwhendown": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
Default: 2,
},
"notifyagainevery": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
},
"notifywhenbackup": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
Computed: true,
Default: true,
},
"integrationids": {
Type: schema.TypeSet,
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeInt},
},
"encryption": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
Computed: true,
},
"url": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
Default: "/",
DiffSuppressFunc: diffSuppressIfNotHTTPCheck,
},
"port": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
ValidateFunc: validation.IsPortNumber,
},
"username": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"password": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
Type: schema.TypeString,
Optional: true,
ForceNew: false,
Sensitive: true,
},
"shouldcontain": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"shouldnotcontain": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"postdata": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"requestheaders": {
Type: schema.TypeMap,
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeString},
},
"tags": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
StateFunc: func(val interface{}) string {
return sortString(val.(string), ",")
},
},
"probefilters": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"userids": {
Type: schema.TypeSet,
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeInt},
},
"teamids": {
Type: schema.TypeSet,
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeInt},
},
"stringtosend": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"stringtoexpect": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"expectedip": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"nameserver": {
Type: schema.TypeString,
Optional: true,
ForceNew: false,
},
"verify_certificate": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
Default: true,
DiffSuppressFunc: diffSuppressIfNotHTTPCheck,
},
"ssl_down_days_before": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
Computed: true,
},
},
Expand Down
8 changes: 5 additions & 3 deletions pingdom/resource_pingdom_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/nordcloud/go-pingdom/pingdom"
)

Expand Down Expand Up @@ -49,9 +50,10 @@ func resourcePingdomContact() *schema.Resource {
Required: true,
},
"provider": {
Type: schema.TypeString,
Optional: true,
Default: "nexmo",
Type: schema.TypeString,
Optional: true,
Default: "nexmo",
ValidateFunc: validation.StringInSlice([]string{"nexmo", "bulksms", "esendex", "cellsynt"}, false),
},
},
},
Expand Down
13 changes: 8 additions & 5 deletions pingdom/resource_pingdom_maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package pingdom

import (
"context"
"strconv"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/nordcloud/go-pingdom/pingdom"
"strconv"
"strings"
)

func resourcePingdomMaintenance() *schema.Resource {
Expand Down Expand Up @@ -37,9 +39,10 @@ func resourcePingdomMaintenance() *schema.Resource {
Computed: true,
},
"recurrencetype": {
Type: schema.TypeString,
Optional: true,
Default: "none",
Type: schema.TypeString,
Optional: true,
Default: "none",
ValidateFunc: validation.StringInSlice([]string{"none", "day", "week", "month"}, false),
},
"repeatevery": {
Type: schema.TypeInt,
Expand Down
2 changes: 0 additions & 2 deletions pingdom/resource_pingdom_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ func resourcePingdomTeam() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: false,
},
"member_ids": {
Type: schema.TypeSet,
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeInt},
},
},
Expand Down
25 changes: 15 additions & 10 deletions pingdom/resource_pingdom_tms_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/nordcloud/go-pingdom/pingdom"
)

Expand Down Expand Up @@ -62,10 +63,11 @@ func resourcePingdomTmsCheck() *schema.Resource {
Optional: true,
Elem: &schema.Schema{Type: schema.TypeInt},
},
"interval": { // [5 10 20 60 720 1440]
Type: schema.TypeInt,
Optional: true,
Default: 10,
"interval": {
Type: schema.TypeInt,
Optional: true,
Default: 10,
ValidateFunc: validation.IntInSlice([]int{5, 10, 20, 60, 720, 1440}),
},
"metadata": {
Type: schema.TypeList,
Expand Down Expand Up @@ -95,18 +97,21 @@ func resourcePingdomTmsCheck() *schema.Resource {
},
},
"region": {
Type: schema.TypeString,
Optional: true,
Default: "us-east",
Type: schema.TypeString,
Optional: true,
Default: "us-east",
ValidateFunc: validation.StringInSlice([]string{"us-east", "us-west", "eu", "au"}, false),
},
"send_notification_when_down": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
},
"security_level": {
Type: schema.TypeString,
Optional: true,
Default: "high",
Type: schema.TypeString,
Optional: true,
Default: "high",
ValidateFunc: validation.StringInSlice([]string{"high", "low"}, false),
},
"tags": {
Type: schema.TypeString,
Expand Down

0 comments on commit 78e16da

Please sign in to comment.