Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDKv2] Merge master into sdk-v2 branch #1008

Merged
merged 16 commits into from
Mar 26, 2021
Merged
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
15 changes: 3 additions & 12 deletions .azure-pipelines/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,20 @@ schedules:
resources:
containers:
- container: datadog-agent
image: datadog/agent:7
options: --health-cmd="exit 0" --health-interval=1s
image: datadog/agent:latest
ports:
- 8125:8125
- 8126:8126
env:
DD_API_KEY: $(ddAPIKey)
DD_APM_ENABLED: "true"
DD_APM_NON_LOCAL_TRAFFIC: "true"
DD_LOGS_ENABLED: "true"
DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: "true"
DD_AC_EXCLUDE: "name:datadog-agent"
DD_HOSTNAME: "none"
DD_INSIDE_CI: "true"

jobs:
- job: IntegrationTests
pool:
vmImage: "Ubuntu-16.04"
container:
image: golang:latest
options: >-
-l com.datadoghq.ad.logs="[{\"source\": \"Azure Pipeline\", \"service\": \"terraform-provider-datadog\"}]"


services:
datadog-agent: datadog-agent
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ datadog/*datadog_ip_ranges* @DataDog/integrations-tools-and-librar
docs/data-sources/ip_ranges* @DataDog/integrations-tools-and-libraries @DataDog/team-aaa
datadog/*datadog_logs* @DataDog/integrations-tools-and-libraries @DataDog/logs-backend @DataDog/logs-app
docs/resources/logs* @DataDog/integrations-tools-and-libraries @DataDog/logs-backend @DataDog/logs-app
datadog/*datadog_metric* @DataDog/integrations-tools-and-libraries @DataDog/metrics-intake @DataDog/metrics-query
docs/resources/metric* @DataDog/integrations-tools-and-libraries @DataDog/metrics-intake @DataDog/metrics-query
datadog/*datadog_metric* @DataDog/integrations-tools-and-libraries @DataDog/metrics-intake @DataDog/metrics-query @DataDog/metrics-aggregation
docs/resources/metric* @DataDog/integrations-tools-and-libraries @DataDog/metrics-intake @DataDog/metrics-query @DataDog/metrics-aggregation
datadog/*datadog_monitor* @DataDog/integrations-tools-and-libraries @DataDog/monitor-app
docs/data-sources/monitor* @DataDog/integrations-tools-and-libraries @DataDog/monitor-app
docs/resources/monitor* @DataDog/integrations-tools-and-libraries @DataDog/monitor-app
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
- name: Checkout code
uses: actions/checkout@v2
- name: Vet
Expand Down
37 changes: 19 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
- repo: https://github.com/prettier/prettier
rev: 2.1.1
hooks:
- id: prettier
name: Format all common files
language: node
language_version: 14.12.0
entry: prettier --write --list-different --ignore-unknown
args:
[
--prose-wrap=never,
--embedded-language-formatting=off,
--tab-width=4,
]
additional_dependencies:
# When updating the version of prettier, make sure to check the pre-commit file
# And keep the `entry` here up to date https://github.com/prettier/prettier/blob/master/.pre-commit-hooks.yaml
- [email protected]
repos:
- repo: https://github.com/prettier/prettier
rev: 2.1.1
hooks:
- id: prettier
name: Format all common files
language: node
language_version: 14.12.0
entry: prettier --write --list-different --ignore-unknown
args:
[
--prose-wrap=never,
--embedded-language-formatting=off,
--tab-width=4,
]
additional_dependencies:
# When updating the version of prettier, make sure to check the pre-commit file
# And keep the `entry` here up to date https://github.com/prettier/prettier/blob/master/.pre-commit-hooks.yaml
- [email protected]
81 changes: 56 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
## 2.22.0 (March 3, 2021)

IMPROVEMENTS:

- `datadog_dashboard`: Improve consistency by using response from POST/PUT requests directly to save state ([#909](https://github.com/Datadog/terraform-provider-datadog/pull/909))
- `datadog_downtime`: Improve consistency by using response from POST/PUT requests directly to save state ([#905](https://github.com/Datadog/terraform-provider-datadog/pull/905))
- `datadog_ip_ranges`: Add support for reading ipv4/6 prefixes by location for synthetics ([#934](https://github.com/Datadog/terraform-provider-datadog/pull/934))
- `datadog_logs_archive_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#912](https://github.com/Datadog/terraform-provider-datadog/pull/912))
- `datadog_logs_archive`: Improve consistency by using response from POST/PUT requests directly to save state ([#912](https://github.com/Datadog/terraform-provider-datadog/pull/912))
- `datadog_logs_custom_pipeline`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913))
- `datadog_logs_index_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#915](https://github.com/Datadog/terraform-provider-datadog/pull/915))
- `datadog_logs_index`: Improve consistency by using response from POST/PUT requests directly to save state ([#915](https://github.com/Datadog/terraform-provider-datadog/pull/915))
- `datadog_logs_integration_pipeline`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913))
- `datadog_logs_metric`: Improve consistency by using response from POST/PUT requests directly to save state ([#917](https://github.com/Datadog/terraform-provider-datadog/pull/917))
- `datadog_logs_pipeline_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913))
- `datadog_metric_metadata`: Improve consistency by using response from POST/PUT requests directly to save state ([#922](https://github.com/Datadog/terraform-provider-datadog/pull/922))
- `datadog_monitor`: Add support for `groupby_simple_monitor` option to monitor resource ([#952](https://github.com/Datadog/terraform-provider-datadog/pull/952))
- `datadog_monitor`: Improve consistency by using response from POST/PUT requests directly to save state ([#901](https://github.com/Datadog/terraform-provider-datadog/pull/901))
- `datadog_role`: Improve consistency by using response from POST/PUT requests directly to save state ([#925](https://github.com/Datadog/terraform-provider-datadog/pull/925))
- `datadog_service_level_objective`: Improve consistency by using response from POST/PUT requests directly to save state ([#910](https://github.com/Datadog/terraform-provider-datadog/pull/910))
- `datadog_slo_correction`: Improve consistency by using response from POST/PUT requests directly to save state ([#921](https://github.com/Datadog/terraform-provider-datadog/pull/921))
- `datadog_user`: Improve consistency by using response from POST/PUT requests directly to save state ([#927](https://github.com/Datadog/terraform-provider-datadog/pull/927))
## 2.24.0 (March 22, 2021)

IMPROVEMENTS:

- `datadog_dashboard`: Add `legend_layout` and `legend_columns` to timeseries widget definition ([#992](https://github.com/Datadog/terraform-provider-datadog/pull/992)).

FEATURE:

- `datadog_metric_tag_configuration` Add new resource ([#960](https://github.com/Datadog/terraform-provider-datadog/pull/960)).

## 2.23.0 (March 16, 2021)

IMPROVEMENTS:

- `datadog_dashboard`: Implement support for Geomap Dashboard Widget ([#954](https://github.com/Datadog/terraform-provider-datadog/pull/954)).

FEATURE:

- `datadog_dashboard_json`: Add new dashboard JSON resource ([#950](https://github.com/Datadog/terraform-provider-datadog/pull/950)).

BUGFIXES:

- `datadog_dashboard`: Add a retry on 504 errors when there is a timeout ([#975](https://github.com/Datadog/terraform-provider-datadog/pull/975)).
- `datadog_integration_slack_channel`: Fix issue causing slack channels to not be created in some situations ([#981](https://github.com/Datadog/terraform-provider-datadog/pull/981)).
- `datadog_monitor`: Explicitly check `monitor_id` for `nil` value to fix an issue with terraformer ([#962](https://github.com/Datadog/terraform-provider-datadog/pull/962)).
- `datadog_security_monitoring_default_rule`: Fix issue that prevented default rule cases notifications to be updated ([#956](https://github.com/Datadog/terraform-provider-datadog/pull/956)).

NOTES:

- Update the underlying Datadog go client to v1.0.0-beta.17. See [here](https://github.com/DataDog/datadog-api-client-go/releases/tag/v1.0.0-beta.17) for changes.

## 2.22.0 (March 3, 2021).

IMPROVEMENTS:

- `datadog_dashboard`: Improve consistency by using response from POST/PUT requests directly to save state ([#909](https://github.com/Datadog/terraform-provider-datadog/pull/909)).
- `datadog_downtime`: Improve consistency by using response from POST/PUT requests directly to save state ([#905](https://github.com/Datadog/terraform-provider-datadog/pull/905)).
- `datadog_ip_ranges`: Add support for reading ipv4/6 prefixes by location for synthetics ([#934](https://github.com/Datadog/terraform-provider-datadog/pull/934)).
- `datadog_logs_archive_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#912](https://github.com/Datadog/terraform-provider-datadog/pull/912)).
- `datadog_logs_archive`: Improve consistency by using response from POST/PUT requests directly to save state ([#912](https://github.com/Datadog/terraform-provider-datadog/pull/912)).
- `datadog_logs_custom_pipeline`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913)).
- `datadog_logs_index_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#915](https://github.com/Datadog/terraform-provider-datadog/pull/915)).
- `datadog_logs_index`: Improve consistency by using response from POST/PUT requests directly to save state ([#915](https://github.com/Datadog/terraform-provider-datadog/pull/915)).
- `datadog_logs_integration_pipeline`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913)).
- `datadog_logs_metric`: Improve consistency by using response from POST/PUT requests directly to save state ([#917](https://github.com/Datadog/terraform-provider-datadog/pull/917)).
- `datadog_logs_pipeline_order`: Improve consistency by using response from POST/PUT requests directly to save state ([#913](https://github.com/Datadog/terraform-provider-datadog/pull/913)).
- `datadog_metric_metadata`: Improve consistency by using response from POST/PUT requests directly to save state ([#922](https://github.com/Datadog/terraform-provider-datadog/pull/922)).
- `datadog_monitor`: Add support for `groupby_simple_monitor` option to monitor resource ([#952](https://github.com/Datadog/terraform-provider-datadog/pull/952)).
- `datadog_monitor`: Improve consistency by using response from POST/PUT requests directly to save state ([#901](https://github.com/Datadog/terraform-provider-datadog/pull/901)).
- `datadog_role`: Improve consistency by using response from POST/PUT requests directly to save state ([#925](https://github.com/Datadog/terraform-provider-datadog/pull/925)).
- `datadog_service_level_objective`: Improve consistency by using response from POST/PUT requests directly to save state ([#910](https://github.com/Datadog/terraform-provider-datadog/pull/910)).
- `datadog_slo_correction`: Improve consistency by using response from POST/PUT requests directly to save state ([#921](https://github.com/Datadog/terraform-provider-datadog/pull/921)).
- `datadog_user`: Improve consistency by using response from POST/PUT requests directly to save state ([#927](https://github.com/Datadog/terraform-provider-datadog/pull/927)).

FEATURE:

- `datadog_integration_slack_channel`: Add support for slack channel resource ([#932](https://github.com/Datadog/terraform-provider-datadog/pull/932))
- `datadog_integration_slack_channel`: Add support for slack channel resource ([#932](https://github.com/Datadog/terraform-provider-datadog/pull/932)).

BUGFIXES:

- `datadog_dashboard`: Fix template_variable_presets to support optional template_variables ([#944](https://github.com/Datadog/terraform-provider-datadog/pull/944))
- `datadog_dashboard`: Fix template_variable_presets to support optional template_variables ([#944](https://github.com/Datadog/terraform-provider-datadog/pull/944)).

NOTES:

- `datadog_integration_pagerduty`: Remove deprecation on PagerDuty resource ([#930](https://github.com/Datadog/terraform-provider-datadog/pull/930))
- `datadog_integration_pagerduty`: Remove deprecation on PagerDuty resource ([#930](https://github.com/Datadog/terraform-provider-datadog/pull/930)).
- Update the underlying Datadog go client to v1.0.0-beta.16. See [here](https://github.com/DataDog/datadog-api-client-go/releases/tag/v1.0.0-beta.16) for changes.

## 2.21.0 (February 9, 2021)
Expand Down
5 changes: 3 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
TEST?=$$(go list ./...)
RECORD?=false
GOFMT_FILES?=$$(find . -name '*.go')
GOIMPORTS_FILES?=$$(find . -name '*.go')
PKG_NAME=datadog
DIR=~/.terraform.d/plugins
ZORKIAN_VERSION?=master
API_CLIENT_VERSION?=master
LOCAL_PACKAGE="github.com/terraform-providers/terraform-provider-datadog"

default: build

Expand Down Expand Up @@ -45,7 +46,7 @@ lint: get-test-deps
golint -set_exit_status ./...

fmt:
gofmt -w $(GOFMT_FILES)
goimports -format-only -local $(LOCAL_PACKAGE) -w $(GOIMPORTS_FILES)
terraform fmt -recursive examples

fmtcheck:
Expand Down
49 changes: 29 additions & 20 deletions datadog/data_source_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package datadog

import (
"context"
"fmt"

"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils"

datadogV1 "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
Expand Down Expand Up @@ -39,35 +41,42 @@ func dataSourceDatadogDashboard() *schema.Resource {
}

func dataSourceDatadogDashboardRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

providerConf := meta.(*ProviderConfiguration)
datadogClientV1 := providerConf.DatadogClientV1
authV1 := providerConf.AuthV1

dashResponse, _, err := datadogClientV1.DashboardsApi.ListDashboards(authV1).Execute()

if err != nil {
return utils.TranslateClientErrorDiag(err, "error querying dashboard")
}
err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutRead), func() *resource.RetryError {
dashResponse, httpresp, err := datadogClientV1.DashboardsApi.ListDashboards(authV1).Execute()
if err != nil {
if httpresp != nil && httpresp.StatusCode == 504 {
return resource.RetryableError(utils.TranslateClientError(err, "error querying dashboard, retrying"))
}
return resource.NonRetryableError(utils.TranslateClientError(err, "error querying dashboard"))
}

searchedName := d.Get("name")
var foundDashes []datadogV1.DashboardSummaryDefinition
searchedName := d.Get("name")
var foundDashes []datadogV1.DashboardSummaryDefinition

for _, dash := range dashResponse.GetDashboards() {
if dash.GetTitle() == searchedName {
foundDashes = append(foundDashes, dash)
for _, dash := range dashResponse.GetDashboards() {
if dash.GetTitle() == searchedName {
foundDashes = append(foundDashes, dash)
}
}
if len(foundDashes) == 0 {
return resource.NonRetryableError(fmt.Errorf("Couldn't find a dashboard named %s", searchedName))
} else if len(foundDashes) > 1 {
return resource.NonRetryableError(fmt.Errorf("%s returned more than one dashboard", searchedName))
}
}

if len(foundDashes) == 0 {
return diag.Errorf("Couldn't find a dashboard named %s", searchedName)
} else if len(foundDashes) > 1 {
return diag.Errorf("%s returned more than one dashboard", searchedName)
}
d.SetId(foundDashes[0].GetId())
d.Set("url", foundDashes[0].GetUrl())
d.Set("title", foundDashes[0].GetTitle())

d.SetId(foundDashes[0].GetId())
d.Set("url", foundDashes[0].GetUrl())
d.Set("title", foundDashes[0].GetTitle())
return nil
})
if err != nil {
return diag.FromErr(err)
}

return nil
}
1 change: 1 addition & 0 deletions datadog/internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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/meta"

"github.com/terraform-providers/terraform-provider-datadog/version"
)

Expand Down
10 changes: 9 additions & 1 deletion datadog/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils"
datadogCommunity "github.com/zorkian/go-datadog-api"

"github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils"
)

var (
Expand Down Expand Up @@ -96,6 +97,7 @@ func Provider() *schema.Provider {
"datadog_logs_metric": resourceDatadogLogsMetric(),
"datadog_logs_pipeline_order": resourceDatadogLogsPipelineOrder(),
"datadog_metric_metadata": resourceDatadogMetricMetadata(),
"datadog_metric_tag_configuration": resourceDatadogMetricTagConfiguration(),
"datadog_monitor": resourceDatadogMonitor(),
"datadog_role": resourceDatadogRole(),
"datadog_security_monitoring_default_rule": resourceDatadogSecurityMonitoringDefaultRule(),
Expand Down Expand Up @@ -256,6 +258,12 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
},
)
configV2 := datadogV2.NewConfiguration()
// Enable unstable operations
configV2.SetUnstableOperationEnabled("CreateTagConfiguration", true)
configV2.SetUnstableOperationEnabled("DeleteTagConfiguration", true)
configV2.SetUnstableOperationEnabled("ListTagConfigurationByName", true)
configV2.SetUnstableOperationEnabled("UpdateTagConfiguration", true)

configV2.UserAgent = utils.GetUserAgent(configV2.UserAgent)
configV2.Debug = logging.IsDebugOrHigher()
if apiURL := d.Get("api_url").(string); apiURL != "" {
Expand Down
Loading