@@ -13,6 +13,7 @@ import (
1313 "github.com/hashicorp/terraform-plugin-framework/resource"
1414 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
1515 "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
16+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
1617 "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1718 "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1819 "github.com/hashicorp/terraform-plugin-framework/schema/validator"
@@ -151,31 +152,20 @@ func (m *ProjectResourceModel) Fill(project apiclient.Project) error {
151152 m .Features = types .SetValueMust (types .StringType , sliceutils .Map (func (v string ) attr.Value {
152153 return types .StringValue (v )
153154 }, project .Features ))
154-
155- if ! m .DigestsMinDelay .IsNull () {
156- m .DigestsMinDelay = types .Int64Value (project .DigestsMinDelay )
157- }
158- if ! m .DigestsMaxDelay .IsNull () {
159- m .DigestsMaxDelay = types .Int64Value (project .DigestsMaxDelay )
160- }
161- if ! m .ResolveAge .IsNull () {
162- m .ResolveAge = types .Int64Value (project .ResolveAge )
163- }
155+ m .DigestsMinDelay = types .Int64Value (project .DigestsMinDelay )
156+ m .DigestsMaxDelay = types .Int64Value (project .DigestsMaxDelay )
157+ m .ResolveAge = types .Int64Value (project .ResolveAge )
164158
165159 if m .Filters != nil {
166160 m .Filters .Fill (project )
167161 }
168162
169- if ! m .FingerprintingRules .IsNull () {
170- if strings .TrimRight (m .FingerprintingRules .ValueString (), "\n " ) != project .FingerprintingRules {
171- m .FingerprintingRules = types .StringValue (project .FingerprintingRules )
172- }
163+ if m .FingerprintingRules .IsUnknown () || strings .TrimRight (m .FingerprintingRules .ValueString (), "\n " ) != project .FingerprintingRules {
164+ m .FingerprintingRules = types .StringValue (project .FingerprintingRules )
173165 }
174166
175- if ! m .GroupingEnhancements .IsNull () {
176- if strings .TrimRight (m .GroupingEnhancements .ValueString (), "\n " ) != project .GroupingEnhancements {
177- m .GroupingEnhancements = types .StringValue (project .GroupingEnhancements )
178- }
167+ if m .GroupingEnhancements .IsUnknown () || strings .TrimRight (m .GroupingEnhancements .ValueString (), "\n " ) != project .GroupingEnhancements {
168+ m .GroupingEnhancements = types .StringValue (project .GroupingEnhancements )
179169 }
180170
181171 if m .ClientSecurity != nil {
@@ -260,14 +250,26 @@ func (r *ProjectResource) Schema(ctx context.Context, req resource.SchemaRequest
260250 "digests_min_delay" : schema.Int64Attribute {
261251 Description : "The minimum amount of time (in seconds) to wait between scheduling digests for delivery after the initial scheduling." ,
262252 Optional : true ,
253+ Computed : true ,
254+ PlanModifiers : []planmodifier.Int64 {
255+ int64planmodifier .UseStateForUnknown (),
256+ },
263257 },
264258 "digests_max_delay" : schema.Int64Attribute {
265259 Description : "The maximum amount of time (in seconds) to wait between scheduling digests for delivery." ,
266260 Optional : true ,
261+ Computed : true ,
262+ PlanModifiers : []planmodifier.Int64 {
263+ int64planmodifier .UseStateForUnknown (),
264+ },
267265 },
268266 "resolve_age" : schema.Int64Attribute {
269267 Description : "Hours in which an issue is automatically resolve if not seen after this amount of time." ,
270268 Optional : true ,
269+ Computed : true ,
270+ PlanModifiers : []planmodifier.Int64 {
271+ int64planmodifier .UseStateForUnknown (),
272+ },
271273 },
272274 "filters" : schema.SingleNestedAttribute {
273275 Description : "Custom filters for this project." ,
@@ -302,10 +304,18 @@ func (r *ProjectResource) Schema(ctx context.Context, req resource.SchemaRequest
302304 "fingerprinting_rules" : schema.StringAttribute {
303305 MarkdownDescription : "This can be used to modify the fingerprint rules on the server with custom rules. Rules follow the pattern `matcher:glob -> fingerprint, values`. To learn more about fingerprint rules, [read the docs](https://docs.sentry.io/concepts/data-management/event-grouping/fingerprint-rules/)." ,
304306 Optional : true ,
307+ Computed : true ,
308+ PlanModifiers : []planmodifier.String {
309+ stringplanmodifier .UseStateForUnknown (),
310+ },
305311 },
306312 "grouping_enhancements" : schema.StringAttribute {
307313 MarkdownDescription : "This can be used to enhance the grouping algorithm with custom rules. Rules follow the pattern `matcher:glob [v^]?[+-]flag`. To learn more about stack trace rules, [read the docs](https://docs.sentry.io/concepts/data-management/event-grouping/stack-trace-rules/)." ,
308314 Optional : true ,
315+ Computed : true ,
316+ PlanModifiers : []planmodifier.String {
317+ stringplanmodifier .UseStateForUnknown (),
318+ },
309319 },
310320 },
311321 Blocks : map [string ]schema.Block {
@@ -368,7 +378,7 @@ func (r *ProjectResource) Create(ctx context.Context, req resource.CreateRequest
368378 DefaultRules : data .DefaultRules .ValueBoolPointer (),
369379 }
370380
371- if ! data .Slug .IsNull () && ! data . Slug . IsUnknown () {
381+ if ! data .Slug .IsUnknown () {
372382 createBody .Slug = data .Slug .ValueStringPointer ()
373383 }
374384
@@ -388,19 +398,34 @@ func (r *ProjectResource) Create(ctx context.Context, req resource.CreateRequest
388398
389399 // Update the project
390400 updateBody := apiclient.UpdateOrganizationProjectJSONRequestBody {
391- Name : data .Name .ValueStringPointer (),
392- Platform : data .Platform .ValueStringPointer (),
393- DigestsMinDelay : data .DigestsMinDelay .ValueInt64Pointer (),
394- DigestsMaxDelay : data .DigestsMaxDelay .ValueInt64Pointer (),
395- ResolveAge : data .ResolveAge .ValueInt64Pointer (),
396- FingerprintingRules : data .FingerprintingRules .ValueStringPointer (),
397- GroupingEnhancements : data .GroupingEnhancements .ValueStringPointer (),
401+ Name : data .Name .ValueStringPointer (),
402+ Platform : data .Platform .ValueStringPointer (),
398403 }
399404
400- if ! data .Slug .IsNull () && ! data . Slug . IsUnknown () {
405+ if ! data .Slug .IsUnknown () {
401406 updateBody .Slug = data .Slug .ValueStringPointer ()
402407 }
403408
409+ if ! data .DigestsMinDelay .IsUnknown () {
410+ updateBody .DigestsMinDelay = data .DigestsMinDelay .ValueInt64Pointer ()
411+ }
412+
413+ if ! data .DigestsMaxDelay .IsUnknown () {
414+ updateBody .DigestsMaxDelay = data .DigestsMaxDelay .ValueInt64Pointer ()
415+ }
416+
417+ if ! data .ResolveAge .IsUnknown () {
418+ updateBody .ResolveAge = data .ResolveAge .ValueInt64Pointer ()
419+ }
420+
421+ if ! data .FingerprintingRules .IsUnknown () {
422+ updateBody .FingerprintingRules = data .FingerprintingRules .ValueStringPointer ()
423+ }
424+
425+ if ! data .GroupingEnhancements .IsUnknown () {
426+ updateBody .GroupingEnhancements = data .GroupingEnhancements .ValueStringPointer ()
427+ }
428+
404429 if data .Filters != nil {
405430 options := make (map [string ]interface {})
406431 if data .Filters .BlacklistedIps .IsNull () {
0 commit comments