Skip to content

Commit

Permalink
[terraform][query table widget] Allow for empty text_formats block
Browse files Browse the repository at this point in the history
  • Loading branch information
hyungl committed Sep 26, 2024
1 parent 758a73f commit b694ec8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
6 changes: 4 additions & 2 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4636,10 +4636,12 @@ func buildDatadogQueryTableRequests(terraformRequests *[]interface{}) *[]datadog
if v, ok := terraformRequest["text_formats"].([]interface{}); ok && len(v) != 0 {
datadogQueryTableRequest.TextFormats = make([][]datadogV1.TableWidgetTextFormatRule, len(v))
for i, w := range v {
if c, ok := w.(map[string]interface{})["text_format"]; ok {
if textFormat, ok := c.([]interface{}); ok && len(textFormat) > 0 {
if c, ok := w.(map[string]interface{}); ok {
if textFormat, ok := c["text_format"].([]interface{}); ok && len(textFormat) > 0 {
datadogQueryTableRequest.TextFormats[i] = *buildDatadogQueryTableTextFormat(&textFormat)
}
} else {
datadogQueryTableRequest.TextFormats[i] = []datadogV1.TableWidgetTextFormatRule{}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-09-26T12:27:14.195524-04:00
2024-09-26T13:30:05.203831-04:00
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interactions:
remote_addr: ""
request_uri: ""
body: |
{"description":"Created using the Datadog provider in Terraform","id":"","layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727368034","widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"}}]}
{"description":"Created using the Datadog provider in Terraform","id":"","layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727371805","widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"}}]}
form: {}
headers:
Accept:
Expand All @@ -32,13 +32,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"id":"fqh-jfp-ce4","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727368034","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/fqh-jfp-ce4/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727368034","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":6738084294967127}],"notify_list":[],"created_at":"2024-09-26T16:27:16.843589+00:00","modified_at":"2024-09-26T16:27:16.843589+00:00","template_variable_presets":[],"tags":[]}
{"id":"75s-s5m-uat","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727371805","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/75s-s5m-uat/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727371805","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":2381522262780434}],"notify_list":[],"created_at":"2024-09-26T17:30:07.742946+00:00","modified_at":"2024-09-26T17:30:07.742946+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 365.753417ms
duration: 423.314542ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -55,7 +55,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/fqh-jfp-ce4
url: https://api.datadoghq.com/api/v1/dashboard/75s-s5m-uat
method: GET
response:
proto: HTTP/1.1
Expand All @@ -67,13 +67,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"id":"fqh-jfp-ce4","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727368034","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/fqh-jfp-ce4/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727368034","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":6738084294967127}],"notify_list":[],"created_at":"2024-09-26T16:27:16.843589+00:00","modified_at":"2024-09-26T16:27:16.843589+00:00","template_variable_presets":[],"tags":[]}
{"id":"75s-s5m-uat","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727371805","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/75s-s5m-uat/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727371805","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":2381522262780434}],"notify_list":[],"created_at":"2024-09-26T17:30:07.742946+00:00","modified_at":"2024-09-26T17:30:07.742946+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 115.898375ms
duration: 164.432833ms
- id: 2
request:
proto: HTTP/1.1
Expand All @@ -90,7 +90,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/fqh-jfp-ce4
url: https://api.datadoghq.com/api/v1/dashboard/75s-s5m-uat
method: GET
response:
proto: HTTP/1.1
Expand All @@ -102,13 +102,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"id":"fqh-jfp-ce4","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727368034","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/fqh-jfp-ce4/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727368034","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":6738084294967127}],"notify_list":[],"created_at":"2024-09-26T16:27:16.843589+00:00","modified_at":"2024-09-26T16:27:16.843589+00:00","template_variable_presets":[],"tags":[]}
{"id":"75s-s5m-uat","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727371805","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/75s-s5m-uat/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727371805","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":2381522262780434}],"notify_list":[],"created_at":"2024-09-26T17:30:07.742946+00:00","modified_at":"2024-09-26T17:30:07.742946+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 116.9965ms
duration: 116.99675ms
- id: 3
request:
proto: HTTP/1.1
Expand All @@ -125,7 +125,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/fqh-jfp-ce4
url: https://api.datadoghq.com/api/v1/dashboard/75s-s5m-uat
method: GET
response:
proto: HTTP/1.1
Expand All @@ -137,13 +137,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"id":"fqh-jfp-ce4","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727368034","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/fqh-jfp-ce4/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727368034","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":6738084294967127}],"notify_list":[],"created_at":"2024-09-26T16:27:16.843589+00:00","modified_at":"2024-09-26T16:27:16.843589+00:00","template_variable_presets":[],"tags":[]}
{"id":"75s-s5m-uat","title":"tf-TestAccDatadogDashboardQueryTableWithTextFormats-local-1727371805","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/75s-s5m-uat/tf-testaccdatadogdashboardquerytablewithtextformats-local-1727371805","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_search_bar":"auto","requests":[{"aggregator":"max","alias":"cpu user","cell_display_mode":["number"],"limit":25,"order":"desc","q":"avg:system.cpu.user{account:prod} by {service, team}","text_formats":[[{"match":{"type":"is","value":"test"},"palette":"black_on_light_yellow","replace":{"type":"all","with":"test"}},{"match":{"type":"is","value":"versus"}}],[{"custom_bg_color":"#632CA6","match":{"type":"is","value":"apple"},"palette":"custom_bg"},{"custom_fg_color":"#632CA6","match":{"type":"is","value":"orange"},"palette":"custom_text"}]]}],"time":{"live_span":"1d"},"title":"this is hyung","title_align":"right","title_size":"16","type":"query_table"},"id":2381522262780434}],"notify_list":[],"created_at":"2024-09-26T17:30:07.742946+00:00","modified_at":"2024-09-26T17:30:07.742946+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 122.486208ms
duration: 110.517625ms
- id: 4
request:
proto: HTTP/1.1
Expand All @@ -160,7 +160,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/fqh-jfp-ce4
url: https://api.datadoghq.com/api/v1/dashboard/75s-s5m-uat
method: DELETE
response:
proto: HTTP/1.1
Expand All @@ -172,13 +172,13 @@ interactions:
content_length: -1
uncompressed: true
body: |
{"deleted_dashboard_id":"fqh-jfp-ce4"}
{"deleted_dashboard_id":"75s-s5m-uat"}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 184.456125ms
duration: 159.869166ms
- id: 5
request:
proto: HTTP/1.1
Expand All @@ -195,7 +195,7 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/fqh-jfp-ce4
url: https://api.datadoghq.com/api/v1/dashboard/75s-s5m-uat
method: GET
response:
proto: HTTP/1.1
Expand All @@ -206,10 +206,10 @@ interactions:
trailer: {}
content_length: -1
uncompressed: true
body: '{"errors":["Dashboard with ID fqh-jfp-ce4 not found"]}'
body: '{"errors":["Dashboard with ID 75s-s5m-uat not found"]}'
headers:
Content-Type:
- application/json
status: 404 Not Found
code: 404
duration: 95.84825ms
duration: 100.581833ms
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-09-26T12:27:14.195456-04:00
2024-09-26T13:30:05.203725-04:00
Loading

0 comments on commit b694ec8

Please sign in to comment.