Skip to content

Commit 7a733ac

Browse files
committed
fix: convert subfilters to set from list (#421)
1 parent 130badf commit 7a733ac

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

docs/resources/project_inbound_data_filter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ resource "sentry_project_inbound_data_filter" "test" {
5252
### Optional
5353

5454
- `active` (Boolean) Toggle the browser-extensions, localhost, filtered-transaction, or web-crawlers filter on or off.
55-
- `subfilters` (List of String) Specifies which legacy browser filters should be active. Anything excluded from the list will be disabled. See the [Sentry documentation](https://docs.sentry.io/api/projects/update-an-inbound-data-filter/) for a list of available subfilters.
55+
- `subfilters` (Set of String) Specifies which legacy browser filters should be active. Anything excluded from the list will be disabled. See the [Sentry documentation](https://docs.sentry.io/api/projects/update-an-inbound-data-filter/) for a list of available subfilters.
5656

5757
### Read-Only
5858

internal/provider/resource_project_inbound_data_filter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http"
77

88
"github.com/hashicorp/terraform-plugin-framework-validators/boolvalidator"
9-
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
9+
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
1010
"github.com/hashicorp/terraform-plugin-framework/attr"
1111
"github.com/hashicorp/terraform-plugin-framework/path"
1212
"github.com/hashicorp/terraform-plugin-framework/resource"
@@ -35,7 +35,7 @@ type ProjectInboundDataFilterResourceModel struct {
3535
Project types.String `tfsdk:"project"`
3636
FilterId types.String `tfsdk:"filter_id"`
3737
Active types.Bool `tfsdk:"active"`
38-
Subfilters types.List `tfsdk:"subfilters"`
38+
Subfilters types.Set `tfsdk:"subfilters"`
3939
}
4040

4141
func (m *ProjectInboundDataFilterResourceModel) Fill(organization string, project string, filterId string, filter sentry.ProjectInboundDataFilter) error {
@@ -52,7 +52,7 @@ func (m *ProjectInboundDataFilterResourceModel) Fill(organization string, projec
5252
subfilterElements = append(subfilterElements, types.StringValue(subfilter))
5353
}
5454

55-
m.Subfilters = types.ListValueMust(types.StringType, subfilterElements)
55+
m.Subfilters = types.SetValueMust(types.StringType, subfilterElements)
5656
}
5757

5858
return nil
@@ -95,12 +95,12 @@ func (r *ProjectInboundDataFilterResource) Schema(ctx context.Context, req resou
9595
),
9696
},
9797
},
98-
"subfilters": schema.ListAttribute{
98+
"subfilters": schema.SetAttribute{
9999
Description: "Specifies which legacy browser filters should be active. Anything excluded from the list will be disabled. See the [Sentry documentation](https://docs.sentry.io/api/projects/update-an-inbound-data-filter/) for a list of available subfilters.",
100100
Optional: true,
101101
ElementType: types.StringType,
102-
Validators: []validator.List{
103-
listvalidator.ConflictsWith(
102+
Validators: []validator.Set{
103+
setvalidator.ConflictsWith(
104104
path.MatchRelative().AtParent().AtName("active"),
105105
),
106106
},

internal/provider/resource_project_inbound_data_filter_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,28 @@ func TestAccProjectInboundDataFilterResource_LegacyBrowser(t *testing.T) {
5858
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
5959
Steps: []resource.TestStep{
6060
{
61-
Config: testAccProjectInboundDataFilterConfig(team, project, filterId, "subfilters = [\"ie_pre_9\"]"),
61+
Config: testAccProjectInboundDataFilterConfig(team, project, filterId, "subfilters = [\"android_pre_4\", \"ie_pre_9\"]"),
6262
Check: resource.ComposeTestCheckFunc(
6363
resource.TestCheckResourceAttr(rn, "organization", acctest.TestOrganization),
6464
resource.TestCheckResourceAttr(rn, "project", project),
6565
resource.TestCheckResourceAttr(rn, "filter_id", filterId),
6666
resource.TestCheckNoResourceAttr(rn, "active"),
67-
resource.TestCheckResourceAttr(rn, "subfilters.#", "1"),
68-
resource.TestCheckResourceAttr(rn, "subfilters.0", "ie_pre_9"),
67+
resource.TestCheckResourceAttr(rn, "subfilters.#", "2"),
68+
resource.TestCheckResourceAttr(rn, "subfilters.0", "android_pre_4"),
69+
resource.TestCheckResourceAttr(rn, "subfilters.1", "ie_pre_9"),
6970
),
7071
},
72+
// NOTE: Intentionally not sorting subfilters to show that the order does not matter during import.
7173
{
72-
Config: testAccProjectInboundDataFilterConfig(team, project, filterId, "subfilters = [\"safari_pre_6\"]"),
74+
Config: testAccProjectInboundDataFilterConfig(team, project, filterId, "subfilters = [\"safari_pre_6\", \"android_pre_4\"]"),
7375
Check: resource.ComposeTestCheckFunc(
7476
resource.TestCheckResourceAttr(rn, "organization", acctest.TestOrganization),
7577
resource.TestCheckResourceAttr(rn, "project", project),
7678
resource.TestCheckResourceAttr(rn, "filter_id", filterId),
7779
resource.TestCheckNoResourceAttr(rn, "active"),
78-
resource.TestCheckResourceAttr(rn, "subfilters.#", "1"),
79-
resource.TestCheckResourceAttr(rn, "subfilters.0", "safari_pre_6"),
80+
resource.TestCheckResourceAttr(rn, "subfilters.#", "2"),
81+
resource.TestCheckResourceAttr(rn, "subfilters.0", "android_pre_4"),
82+
resource.TestCheckResourceAttr(rn, "subfilters.1", "safari_pre_6"),
8083
),
8184
},
8285
{

0 commit comments

Comments
 (0)