Skip to content

Commit 5b4e716

Browse files
authored
Fix filtering on tags for nodebalancers (#2167)
1 parent 7fa7a77 commit 5b4e716

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

linode/nbs/datasource_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ func TestAccDataSourceNodeBalancers_basic(t *testing.T) {
6262
resource.TestCheckResourceAttr(resourceName, "nodebalancers.#", "0"),
6363
),
6464
},
65+
{
66+
Config: tmpl.DataFilterTags(t, nbLabel, nbRegion),
67+
Check: resource.ComposeTestCheckFunc(
68+
resource.TestCheckResourceAttr(resourceName, "nodebalancers.#", "1"),
69+
resource.TestCheckResourceAttr(resourceName, "nodebalancers.0.region", nbRegion),
70+
acceptance.CheckListContains(resourceName, "nodebalancers.0.tags", "tf_test_2"),
71+
),
72+
},
6573
{
6674
Config: tmpl.DataOrder(t, nbLabel, nbRegion),
6775
Check: resource.ComposeTestCheckFunc(

linode/nbs/framework_schema_datasource.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import (
88

99
var filterConfig = frameworkfilter.Config{
1010
"label": {APIFilterable: true, TypeFunc: frameworkfilter.FilterTypeString},
11-
"tags": {APIFilterable: true, TypeFunc: frameworkfilter.FilterTypeString},
1211
"ipv4": {APIFilterable: true, TypeFunc: frameworkfilter.FilterTypeString},
1312
"region": {APIFilterable: true, TypeFunc: frameworkfilter.FilterTypeString},
1413

14+
// temporarily use client-side filter while API filter for tags is not working properly
15+
"tags": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
16+
1517
"hostname": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
1618
"ipv6": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeString},
1719
"client_conn_throttle": {APIFilterable: false, TypeFunc: frameworkfilter.FilterTypeInt},
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{ define "nbs_data_filter_tags" }}
2+
3+
{{ template "nbs_data_base" . }}
4+
5+
data "linode_nodebalancers" "nbs" {
6+
filter {
7+
name = "tags"
8+
values = ["tf_test_2"]
9+
}
10+
filter {
11+
name = "region"
12+
values = ["{{.Region}}"]
13+
}
14+
}
15+
16+
{{ end }}

linode/nbs/tmpl/template.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,11 @@ func DataOrder(t testing.TB, label, region string) string {
4242
Region: region,
4343
})
4444
}
45+
46+
func DataFilterTags(t testing.TB, label, region string) string {
47+
return acceptance.ExecuteTemplate(t,
48+
"nbs_data_filter_tags", TemplateData{
49+
Label: label,
50+
Region: region,
51+
})
52+
}

0 commit comments

Comments
 (0)