Skip to content

Commit

Permalink
Merge pull request #3 from terraform-providers/master
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
enbashi authored Jun 26, 2019
2 parents b56b7ca + 31e2989 commit 7692051
Show file tree
Hide file tree
Showing 236 changed files with 70,361 additions and 3,943 deletions.
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
## 1.10.0 (Unreleased)
## 2.1.0 (Unreleased)
## 2.0.2 (June 26, 2019)

BUGFIXES:
* `datadog_monitor`: DiffSuppress the difference between `metric alert` and `query alert` no matter what is in the current state and prevent the force recreation of monitors due to this change. ([#247](https://github.com/terraform-providers/terraform-provider-datadog/issues/247))

## 2.0.1 (June 21, 2019)

BUGFIXES:
* `datadog_monitor`: Don't force the destruction and recreation of a monitor when the type changes between `metric alert` and `query alert`. ([#242](https://github.com/terraform-providers/terraform-provider-datadog/issues/242))

## 2.0.0 (June 18, 2019)

NOTES:
* `datadog_monitor`: The silence attribute is beginning its deprecation process, please use `datadog_downtime` instead ([#221](https://github.com/terraform-providers/terraform-provider-datadog/issues/221))

IMPROVEMENTS:
* `datadog_monitor`: Use ForceNew when changing the Monitor type ([#236](https://github.com/terraform-providers/terraform-provider-datadog/issues/236))
* `datadog_monitor`: Add default to `no data` timeframe of 10 minutes. ([#212](https://github.com/terraform-providers/terraform-provider-datadog/issues/212))
* `datadog_synthetics_test`: Support synthetics monitors in composite monitors. ([#222](https://github.com/terraform-providers/terraform-provider-datadog/issues/222))
* `datadog_downtime`: Add validation to tags, add timezone parameter, improve downtime id handling, add descriptions to fields. ([#204](https://github.com/terraform-providers/terraform-provider-datadog/issues/204))
* `datadog_screenboard`: Add support for metadata alias in graphs. ([#215](https://github.com/terraform-providers/terraform-provider-datadog/issues/215))
* `datadog_screenboard`: Add `custom_bg_color` to graph config. [[#189](https://github.com/terraform-providers/terraform-provider-datadog/issues/189)] Thanks [@milanvdm](https://github.com/milanvdm)
* Update the vendored go client to `v2.21.0`. ([#230](https://github.com/terraform-providers/terraform-provider-datadog/issues/230))

BUGFIXES:
* `datadog_timeboard`: Fix the `extra_col` from having a non empty plan when there are no changes. ([#231](https://github.com/terraform-providers/terraform-provider-datadog/issues/231))
* `datadog_timeboard`: Fix the `precision` from having a non empty plan when there are no changes. ([#228](https://github.com/terraform-providers/terraform-provider-datadog/issues/228))
* `datadog_monitor`: Fix the sorting of monitor tags that could lead to a non empty diff. ([#214](https://github.com/terraform-providers/terraform-provider-datadog/issues/214))
* `datadog_monitor`: Properly save `query_config` as to avoid to an improper non empty diff. ([#209](https://github.com/terraform-providers/terraform-provider-datadog/issues/209))
* `datadog_monitor`: Fix and clarify documentation on unmuting monitor scopes. ([#202](https://github.com/terraform-providers/terraform-provider-datadog/issues/202))
* `datadog_screenboard`: Change monitor schema to be of type String instead of Int. [[#154](https://github.com/terraform-providers/terraform-provider-datadog/issues/154)] Thanks [@mnaboka](https://github.com/mnaboka)

## 1.9.0 (May 09, 2019)

IMPROVEMENTS:
Expand Down
1 change: 1 addition & 0 deletions datadog/import_datadog_downtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "datadog_downtime" "foo" {
scope = ["host:X", "host:Y"]
start = 1735707600
end = 1735765200
timezone = "UTC"
message = "Example Datadog downtime message."
monitor_tags = ["*"]
Expand Down
77 changes: 62 additions & 15 deletions datadog/resource_datadog_downtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ func resourceDatadogDowntime() *schema.Resource {
_, recurrencePresent := d.GetOk("recurrence")
return recurrencePresent
},
Description: "When true indicates this downtime is being actively applied",
},
"disabled": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Description: "When true indicates this downtime is not being applied",
},
"start": {
Type: schema.TypeInt,
Expand All @@ -43,6 +45,7 @@ func resourceDatadogDowntime() *schema.Resource {
_, startDatePresent := d.GetOk("start_date")
return startDatePresent
},
Description: "Specify when this downtime should start",
},
"start_date": {
Type: schema.TypeString,
Expand All @@ -57,24 +60,34 @@ func resourceDatadogDowntime() *schema.Resource {
_, endDatePresent := d.GetOk("end_date")
return endDatePresent
},
Description: "Optionally specify an end date when this downtime should expire",
},
"end_date": {
Type: schema.TypeString,
ValidateFunc: validation.ValidateRFC3339TimeString,
ConflictsWith: []string{"end"},
Optional: true,
},
"timezone": {
Type: schema.TypeString,
Default: "UTC",
Optional: true,
Description: "The timezone for the downtime, default UTC",
ValidateFunc: validateDatadogDowntimeTimezone,
},
"message": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
Description: "An optional message to provide when creating the downtime, can include notification handles",
StateFunc: func(val interface{}) string {
return strings.TrimSpace(val.(string))
},
},
"recurrence": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Optional recurring schedule for this downtime",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"period": {
Expand Down Expand Up @@ -108,18 +121,23 @@ func resourceDatadogDowntime() *schema.Resource {
},
},
"scope": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "specify the group scope to which this downtime applies. For everything use '*'",
},
"monitor_id": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
ConflictsWith: []string{"monitor_tags"},
Description: "When specified, this downtime will only apply to this monitor",
},
"monitor_tags": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeList,
Optional: true,
Description: "A list of monitor tags (up to 25), i.e. tags that are applied directly to monitors to which the downtime applies",
ConflictsWith: []string{"monitor_id"},
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
Expand Down Expand Up @@ -190,6 +208,9 @@ func buildDowntimeStruct(d *schema.ResourceData) *datadog.Downtime {
} else if attr, ok := d.GetOk("start"); ok {
dt.SetStart(attr.(int))
}
if attr, ok := d.GetOk("timezone"); ok {
dt.SetTimezone(attr.(string))
}

return &dt
}
Expand Down Expand Up @@ -259,6 +280,10 @@ func resourceDatadogDowntimeRead(d *schema.ResourceData, meta interface{}) error
return err
}

if err := d.Set("timezone", dt.GetTimezone()); err != nil {
return err
}

if r, ok := dt.GetRecurrenceOk(); ok {
recurrence := make(map[string]interface{})
recurrenceList := make([]map[string]interface{}, 0, 1)
Expand Down Expand Up @@ -305,6 +330,8 @@ func resourceDatadogDowntimeUpdate(d *schema.ResourceData, meta interface{}) err
if err = client.UpdateDowntime(dt); err != nil {
return fmt.Errorf("error updating downtime: %s", err.Error())
}
// handle the case when a downtime is replaced
d.SetId(strconv.Itoa(dt.GetId()))

return resourceDatadogDowntimeRead(d, meta)
}
Expand Down Expand Up @@ -354,3 +381,23 @@ func validateDatadogDowntimeRecurrenceWeekDays(v interface{}, k string) (ws []st
}
return
}

func validateDatadogDowntimeTimezone(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
switch strings.ToLower(value) {
case "utc", "":
break
case "local", "localtime":
// get current zone from machine
zone, _ := time.Now().Local().Zone()
return validateDatadogDowntimeRecurrenceType(zone, k)
default:
_, err := time.LoadLocation(value)
if err != nil {
errors = append(errors, fmt.Errorf(
"%q contains an invalid timezone parameter: %q, Valid parameters are IANA Time Zone names",
k, value))
}
}
return
}
8 changes: 4 additions & 4 deletions datadog/resource_datadog_integration_gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const testAccCheckDatadogIntegrationGCPConfig = `
resource "datadog_integration_gcp" "awesome_gcp_project_integration" {
project_id = "awesome-project-id"
project_id = "super-awesome-project-id"
private_key_id = "1234567890123456789012345678901234567890"
private_key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
client_email = "awesome-service-account@awesome-project-id.iam.gserviceaccount.com"
Expand All @@ -21,7 +21,7 @@ resource "datadog_integration_gcp" "awesome_gcp_project_integration" {
`
const testAccCheckDatadogIntegrationGCPEmptyHostFiltersConfig = `
resource "datadog_integration_gcp" "awesome_gcp_project_integration" {
project_id = "awesome-project-id"
project_id = "super-awesome-project-id"
private_key_id = "1234567890123456789012345678901234567890"
private_key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
client_email = "awesome-service-account@awesome-project-id.iam.gserviceaccount.com"
Expand All @@ -41,7 +41,7 @@ func TestAccDatadogIntegrationGCP(t *testing.T) {
checkIntegrationGCPExists,
resource.TestCheckResourceAttr(
"datadog_integration_gcp.awesome_gcp_project_integration",
"project_id", "awesome-project-id"),
"project_id", "super-awesome-project-id"),
resource.TestCheckResourceAttr(
"datadog_integration_gcp.awesome_gcp_project_integration",
"private_key_id", "1234567890123456789012345678901234567890"),
Expand All @@ -65,7 +65,7 @@ func TestAccDatadogIntegrationGCP(t *testing.T) {
checkIntegrationGCPExists,
resource.TestCheckResourceAttr(
"datadog_integration_gcp.awesome_gcp_project_integration",
"project_id", "awesome-project-id"),
"project_id", "super-awesome-project-id"),
resource.TestCheckResourceAttr(
"datadog_integration_gcp.awesome_gcp_project_integration",
"private_key_id", "1234567890123456789012345678901234567890"),
Expand Down
Loading

0 comments on commit 7692051

Please sign in to comment.