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

Add applyIfExists for dashboard vars/filters #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The following arguments are supported in the resource block:
* `property` - (Required) A metric time series dimension or property name.
* `not` - (Optional) Whether this filter should be a not filter. `false` by default.
* `values` - (Required) List of of strings (which will be treated as an OR filter on the property).
* `apply_if_exist` - (Optional) If true, this filter will also match data that doesn't have this property at all.
* `variable` - (Optional) Dashboard variable to apply to each chart in the dashboard.
* `property` - (Required) A metric time series dimension or property name.
* `alias` - (Required) An alias for the dashboard variable. This text will appear as the label for the dropdown field on the dashboard.
Expand All @@ -61,6 +62,7 @@ The following arguments are supported in the resource block:
* `values_suggested` - (Optional) A list of strings of suggested values for this variable; these suggestions will receive priority when values are autosuggested for this variable.
* `restricted_suggestions` - (Optional) If `true`, this variable may only be set to the values listed in `values_suggested` and only these values will appear in autosuggestion menus. `false` by default.
* `replace_only` - (Optional) If `true`, this variable will only apply to charts that have a filter for the property.
* `apply_if_exist` - (Optional) If true, this variable will also match data that doesn't have this property at all.
* `chart` - (Optional) Chart ID and layout information for the charts in the dashboard.
* `chart_id` - (Required) ID of the chart to display.
* `width` - (Optional) How many columns (out of a total of 12) the chart should take up (between `1` and `12`). `12` by default.
Expand Down
14 changes: 14 additions & 0 deletions src/terraform-provider-signalform/signalform/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ func dashboardResource() *schema.Resource {
Default: false,
Description: "If true, this variable will only apply to charts with a filter on the named property.",
},
"apply_if_exist": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, this variable will also match data that does not have the specified property",
},
},
},
},
Expand All @@ -269,6 +275,12 @@ func dashboardResource() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
Description: "List of strings (which will be treated as an OR filter on the property)",
},
"apply_if_exist": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, this filter will also match data that does not have the specified property",
},
},
},
},
Expand Down Expand Up @@ -444,6 +456,7 @@ func getDashboardVariables(d *schema.ResourceData) []map[string]interface{} {
}
}
item["restricted"] = variable["restricted_suggestions"].(bool)
item["applyIfExists"] = variable["apply_if_exist"].(bool)

item["replaceOnly"] = variable["replace_only"].(bool)

Expand All @@ -461,6 +474,7 @@ func getDashboardFilters(d *schema.ResourceData) []map[string]interface{} {

item["property"] = filter["property"].(string)
item["NOT"] = filter["negated"].(bool)
item["applyIfExists"] = filter["apply_if_exist"].(bool)
item["value"] = filter["values"].(*schema.Set).List()

filter_list[i] = item
Expand Down