@@ -11,6 +11,7 @@ import (
1111 "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
1212 "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1313 "github.com/hashicorp/terraform-plugin-framework/attr"
14+ "github.com/hashicorp/terraform-plugin-framework/diag"
1415 "github.com/hashicorp/terraform-plugin-framework/path"
1516 "github.com/hashicorp/terraform-plugin-framework/resource"
1617 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -19,6 +20,7 @@ import (
1920 "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
2021 "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
2122 "github.com/hashicorp/terraform-plugin-framework/schema/validator"
23+ "github.com/hashicorp/terraform-plugin-framework/tfsdk"
2224 "github.com/hashicorp/terraform-plugin-framework/types"
2325 "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
2426 "github.com/hashicorp/terraform-plugin-log/tflog"
@@ -924,7 +926,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
924926 }
925927
926928 // Set state to fully populated data
927- diags = resp .State . Set ( ctx , model )
929+ diags = setACL ( ctx , resp .State , & model )
928930 resp .Diagnostics .Append (diags ... )
929931 if resp .Diagnostics .HasError () {
930932 return
@@ -966,7 +968,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
966968 }
967969
968970 // Set state to fully populated data
969- diags = resp .State . Set ( ctx , model )
971+ diags = setMetricsRetentions ( ctx , resp .State , & model )
970972 resp .Diagnostics .Append (diags ... )
971973 if resp .Diagnostics .HasError () {
972974 return
@@ -1010,7 +1012,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
10101012 }
10111013
10121014 // Set state to fully populated data
1013- diags = resp .State . Set ( ctx , model )
1015+ diags = setAlertConfig ( ctx , resp .State , & model )
10141016 resp .Diagnostics .Append (diags ... )
10151017 if resp .Diagnostics .HasError () {
10161018 return
@@ -1192,8 +1194,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
11921194 }
11931195
11941196 // Set state to ACL populated data
1195- diags = resp .State .Set (ctx , model )
1196- resp .Diagnostics .Append (diags ... )
1197+ resp .Diagnostics .Append (setACL (ctx , resp .State , & model )... )
11971198 if resp .Diagnostics .HasError () {
11981199 return
11991200 }
@@ -1233,7 +1234,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
12331234 return
12341235 }
12351236 // Set state to fully populated data
1236- diags = resp .State . Set ( ctx , model )
1237+ diags = setMetricsRetentions ( ctx , resp .State , & model )
12371238 resp .Diagnostics .Append (diags ... )
12381239 if resp .Diagnostics .HasError () {
12391240 return
@@ -1277,7 +1278,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
12771278 }
12781279
12791280 // Set state to fully populated data
1280- diags = resp .State . Set ( ctx , model )
1281+ diags = setAlertConfig ( ctx , resp .State , & model )
12811282 resp .Diagnostics .Append (diags ... )
12821283 if resp .Diagnostics .HasError () {
12831284 return
@@ -2234,3 +2235,18 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
22342235 }
22352236 return nil
22362237}
2238+
2239+ func setACL (ctx context.Context , state tfsdk.State , model * Model ) diag.Diagnostics {
2240+ return state .SetAttribute (ctx , path .Root ("acl" ), model .ACL )
2241+ }
2242+
2243+ func setMetricsRetentions (ctx context.Context , state tfsdk.State , model * Model ) (diags diag.Diagnostics ) {
2244+ diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days" ), model .MetricsRetentionDays )... )
2245+ diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days_5m_downsampling" ), model .MetricsRetentionDays5mDownsampling )... )
2246+ diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days_1h_downsampling" ), model .MetricsRetentionDays1hDownsampling )... )
2247+ return diags
2248+ }
2249+
2250+ func setAlertConfig (ctx context.Context , state tfsdk.State , model * Model ) diag.Diagnostics {
2251+ return state .SetAttribute (ctx , path .Root ("alert_config" ), model .AlertConfig )
2252+ }
0 commit comments