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

[graph-editor] Add support for WidgetCustomLink is_hidden and override_label properties #1062

Merged
merged 26 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
818f814
[graph-editor] Add support for context menu override for custom_links
qincchen May 11, 2021
7c13054
Merge branch 'master' into qin.chen/ctx-menu-link
qincchen May 11, 2021
c5c8986
stash
qincchen May 13, 2021
3e43898
ready for review
qincchen May 13, 2021
452045b
clean up changes
qincchen May 13, 2021
e63eed4
update logic to handle field selection
qincchen May 14, 2021
9a8c248
update client
qincchen May 19, 2021
867441f
Merge branch 'master' into qin.chen/ctx-menu-link
qincchen May 19, 2021
42e231b
revert change
qincchen May 19, 2021
3b1d57b
make docs
qincchen May 19, 2021
5353998
add test
qincchen May 24, 2021
f4272e2
Merge branch 'master' into qin.chen/ctx-menu-link
qincchen May 24, 2021
eefcad3
fix test
qincchen May 24, 2021
eeae881
revert cassettes change
qincchen May 24, 2021
0c1cbc7
fix TestAccDatadogDashboardTopList
qincchen May 24, 2021
fba61d5
revert datadog/tests/cassettes changes
qincchen May 24, 2021
642e29f
try to fix TestAccDatadogDashboardGeomap
qincchen May 25, 2021
da9d56a
try fix TestAccDatadogDashboardTimeseries
qincchen May 25, 2021
ef4b70b
fix more tests
qincchen May 25, 2021
bb90c45
try to fix TestAccDatadogDashboardTopList
qincchen May 25, 2021
23fb7d3
Merge branch 'master' into qin.chen/ctx-menu-link
qincchen Jun 7, 2021
3f3906d
add cassettes
qincchen Jun 7, 2021
91e01c7
Update datadog/resource_datadog_dashboard.go
qincchen Jun 8, 2021
670dee8
Update datadog/resource_datadog_dashboard.go
qincchen Jun 8, 2021
814c53a
update make docs
qincchen Jun 8, 2021
5edf648
add period
qincchen Jun 8, 2021
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
53 changes: 41 additions & 12 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -6180,35 +6180,64 @@ func getWidgetCustomLinkSchema() map[string]*schema.Schema {
"label": {
Description: "The label for the custom link URL.",
Type: schema.TypeString,
Required: true,
Optional: true,
},
"link": {
Description: "The URL of the custom link.",
Type: schema.TypeString,
Required: true,
Optional: true,
},
"is_hidden": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part it looks good to me. The perpetual diff when both are set might be something we have to live with. Not sure of any viable/clean workarounds unless the rest of the team has any ideas. Could you also add a tests for the new fields please. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skarimo what causes the perpetual diff ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted outside of the Github issue but to close the loop here, the perpetual diff is caused when both label and label_override is set.

We can keep the behavior as is but let's document that both fields should not be set at the same time.

Description: "The flag for toggling context menu link visibility",
qincchen marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeBool,
Optional: true,
},
"override_label": {
Description: "The label id that refers to a context menu link item",
qincchen marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Optional: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not use ConflictsWith property here due to custom_link being in a list.

See hashicorp/terraform-plugin-sdk#71

},
}
}
func buildDatadogWidgetCustomLinks(terraformWidgetCustomLinks *[]interface{}) *[]datadogV1.WidgetCustomLink {
datadogWidgetCustomLinks := make([]datadogV1.WidgetCustomLink, len(*terraformWidgetCustomLinks))
for i, customLink := range *terraformWidgetCustomLinks {
terraformCustomLink := customLink.(map[string]interface{})
datadogWidgetCustomLink := datadogV1.WidgetCustomLink{
Label: datadogV1.PtrString(terraformCustomLink["label"].(string)),
Link: datadogV1.PtrString(terraformCustomLink["link"].(string)),
datadogWidgetCustomLink := datadogV1.WidgetCustomLink{}
if v, ok := terraformCustomLink["override_label"].(string); ok && len(v) > 0 {
datadogWidgetCustomLink.SetOverrideLabel(v)
}
// if override_label is provided, it would context menu override, thus omit label field
if v, ok := terraformCustomLink["label"].(string); ok && len(v) > 0 && !datadogWidgetCustomLink.HasOverrideLabel() {
datadogWidgetCustomLink.SetLabel(v)
}
if v, ok := terraformCustomLink["is_hidden"].(bool); ok && v && datadogWidgetCustomLink.HasOverrideLabel() {
datadogWidgetCustomLink.SetIsHidden(v)
}
if v, ok := terraformCustomLink["link"].(string); ok && len(v) > 0 {
datadogWidgetCustomLink.SetLink(v)
}
datadogWidgetCustomLinks[i] = datadogWidgetCustomLink
}
return &datadogWidgetCustomLinks
}
func buildTerraformWidgetCustomLinks(datadogWidgetCustomLinks *[]datadogV1.WidgetCustomLink) *[]map[string]string {
terraformWidgetCustomLinks := make([]map[string]string, len(*datadogWidgetCustomLinks))
func buildTerraformWidgetCustomLinks(datadogWidgetCustomLinks *[]datadogV1.WidgetCustomLink) *[]map[string]interface{} {
terraformWidgetCustomLinks := make([]map[string]interface{}, len(*datadogWidgetCustomLinks))
for i, customLink := range *datadogWidgetCustomLinks {
terraformWidgetCustomLink := map[string]string{}
// Required params
terraformWidgetCustomLink["label"] = customLink.GetLabel()
terraformWidgetCustomLink["link"] = customLink.GetLink()

terraformWidgetCustomLink := map[string]interface{}{}
// Optional params
if v, ok := customLink.GetLabelOk(); ok {
terraformWidgetCustomLink["label"] = *v
}
if v, ok := customLink.GetLinkOk(); ok {
terraformWidgetCustomLink["link"] = *v
}
if v, ok := customLink.GetOverrideLabelOk(); ok {
terraformWidgetCustomLink["override_label"] = *v
}
if v, ok := customLink.GetIsHiddenOk(); ok {
terraformWidgetCustomLink["is_hidden"] = *v
}
terraformWidgetCustomLinks[i] = terraformWidgetCustomLink
}
return &terraformWidgetCustomLinks
Expand Down
80 changes: 60 additions & 20 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,12 @@ Optional:
<a id="nestedblock--widget--change_definition--custom_link"></a>
### Nested Schema for `widget.change_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--change_definition--request"></a>
Expand Down Expand Up @@ -1496,10 +1498,12 @@ Required:
<a id="nestedblock--widget--geomap_definition--custom_link"></a>
### Nested Schema for `widget.geomap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--geomap_definition--request"></a>
Expand Down Expand Up @@ -1887,10 +1891,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--change_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.change_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--change_definition--request"></a>
Expand Down Expand Up @@ -2611,10 +2617,12 @@ Required:
<a id="nestedblock--widget--group_definition--widget--geomap_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.geomap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--geomap_definition--request"></a>
Expand Down Expand Up @@ -2921,10 +2929,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--heatmap_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.heatmap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--heatmap_definition--event"></a>
Expand Down Expand Up @@ -3276,10 +3286,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--hostmap_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.hostmap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--hostmap_definition--request"></a>
Expand Down Expand Up @@ -4006,10 +4018,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--query_table_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.query_table_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--query_table_definition--request"></a>
Expand Down Expand Up @@ -4385,10 +4399,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--query_value_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.query_value_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--query_value_definition--request"></a>
Expand Down Expand Up @@ -4857,10 +4873,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--scatterplot_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.scatterplot_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--scatterplot_definition--request"></a>
Expand Down Expand Up @@ -5526,10 +5544,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--servicemap_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.servicemap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item



Expand Down Expand Up @@ -5557,10 +5577,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.timeseries_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--timeseries_definition--event"></a>
Expand Down Expand Up @@ -6148,10 +6170,12 @@ Optional:
<a id="nestedblock--widget--group_definition--widget--toplist_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.toplist_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--group_definition--widget--toplist_definition--request"></a>
Expand Down Expand Up @@ -6672,10 +6696,12 @@ Optional:
<a id="nestedblock--widget--heatmap_definition--custom_link"></a>
### Nested Schema for `widget.heatmap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--heatmap_definition--event"></a>
Expand Down Expand Up @@ -7027,10 +7053,12 @@ Optional:
<a id="nestedblock--widget--hostmap_definition--custom_link"></a>
### Nested Schema for `widget.hostmap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--hostmap_definition--request"></a>
Expand Down Expand Up @@ -7757,10 +7785,12 @@ Optional:
<a id="nestedblock--widget--query_table_definition--custom_link"></a>
### Nested Schema for `widget.query_table_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--query_table_definition--request"></a>
Expand Down Expand Up @@ -8136,10 +8166,12 @@ Optional:
<a id="nestedblock--widget--query_value_definition--custom_link"></a>
### Nested Schema for `widget.query_value_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--query_value_definition--request"></a>
Expand Down Expand Up @@ -8608,10 +8640,12 @@ Optional:
<a id="nestedblock--widget--scatterplot_definition--custom_link"></a>
### Nested Schema for `widget.scatterplot_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--scatterplot_definition--request"></a>
Expand Down Expand Up @@ -9277,10 +9311,12 @@ Optional:
<a id="nestedblock--widget--servicemap_definition--custom_link"></a>
### Nested Schema for `widget.servicemap_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item



Expand Down Expand Up @@ -9308,10 +9344,12 @@ Optional:
<a id="nestedblock--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.timeseries_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--timeseries_definition--event"></a>
Expand Down Expand Up @@ -9899,10 +9937,12 @@ Optional:
<a id="nestedblock--widget--toplist_definition--custom_link"></a>
### Nested Schema for `widget.toplist_definition.custom_link`

Required:
Optional:

- **is_hidden** (Boolean) The flag for toggling context menu link visibility
- **label** (String) The label for the custom link URL.
- **link** (String) The URL of the custom link.
- **override_label** (String) The label id that refers to a context menu link item


<a id="nestedblock--widget--toplist_definition--request"></a>
Expand Down