@@ -926,7 +926,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
926926 }
927927
928928 // Set state to fully populated data
929- diags = setACL (ctx , resp .State , & model )
929+ diags = setACL (ctx , & resp .State , & model )
930930 resp .Diagnostics .Append (diags ... )
931931 if resp .Diagnostics .HasError () {
932932 return
@@ -968,7 +968,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
968968 }
969969
970970 // Set state to fully populated data
971- diags = setMetricsRetentions (ctx , resp .State , & model )
971+ diags = setMetricsRetentions (ctx , & resp .State , & model )
972972 resp .Diagnostics .Append (diags ... )
973973 if resp .Diagnostics .HasError () {
974974 return
@@ -1012,7 +1012,7 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
10121012 }
10131013
10141014 // Set state to fully populated data
1015- diags = setAlertConfig (ctx , resp .State , & model )
1015+ diags = setAlertConfig (ctx , & resp .State , & model )
10161016 resp .Diagnostics .Append (diags ... )
10171017 if resp .Diagnostics .HasError () {
10181018 return
@@ -1074,20 +1074,41 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
10741074 return
10751075 }
10761076
1077+ // Set state to fully populated data
1078+ diags = resp .State .Set (ctx , model )
1079+ resp .Diagnostics .Append (diags ... )
1080+ if resp .Diagnostics .HasError () {
1081+ return
1082+ }
1083+
10771084 // Map response body to schema
10781085 err = mapACLField (aclListResp , & model )
10791086 if err != nil {
10801087 core .LogAndAddError (ctx , & resp .Diagnostics , "Error reading instance" , fmt .Sprintf ("Processing API response for the ACL: %v" , err ))
10811088 return
10821089 }
10831090
1091+ // Set state to fully populated data
1092+ diags = setACL (ctx , & resp .State , & model )
1093+ resp .Diagnostics .Append (diags ... )
1094+ if resp .Diagnostics .HasError () {
1095+ return
1096+ }
1097+
10841098 // Map response body to schema
10851099 err = mapMetricsRetentionField (metricsRetentionResp , & model )
10861100 if err != nil {
10871101 core .LogAndAddError (ctx , & resp .Diagnostics , "Error reading instance" , fmt .Sprintf ("Processing API response for the metrics retention: %v" , err ))
10881102 return
10891103 }
10901104
1105+ // Set state to fully populated data
1106+ diags = setMetricsRetentions (ctx , & resp .State , & model )
1107+ resp .Diagnostics .Append (diags ... )
1108+ if resp .Diagnostics .HasError () {
1109+ return
1110+ }
1111+
10911112 // Map response body to schema
10921113 err = mapAlertConfigField (ctx , alertConfigResp , & model )
10931114 if err != nil {
@@ -1096,7 +1117,7 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
10961117 }
10971118
10981119 // Set state to fully populated data
1099- diags = resp .State . Set ( ctx , model )
1120+ diags = setAlertConfig ( ctx , & resp .State , & model )
11001121 resp .Diagnostics .Append (diags ... )
11011122 if resp .Diagnostics .HasError () {
11021123 return
@@ -1194,7 +1215,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
11941215 }
11951216
11961217 // Set state to ACL populated data
1197- resp .Diagnostics .Append (setACL (ctx , resp .State , & model )... )
1218+ resp .Diagnostics .Append (setACL (ctx , & resp .State , & model )... )
11981219 if resp .Diagnostics .HasError () {
11991220 return
12001221 }
@@ -1234,7 +1255,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
12341255 return
12351256 }
12361257 // Set state to fully populated data
1237- diags = setMetricsRetentions (ctx , resp .State , & model )
1258+ diags = setMetricsRetentions (ctx , & resp .State , & model )
12381259 resp .Diagnostics .Append (diags ... )
12391260 if resp .Diagnostics .HasError () {
12401261 return
@@ -1278,7 +1299,7 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
12781299 }
12791300
12801301 // Set state to fully populated data
1281- diags = setAlertConfig (ctx , resp .State , & model )
1302+ diags = setAlertConfig (ctx , & resp .State , & model )
12821303 resp .Diagnostics .Append (diags ... )
12831304 if resp .Diagnostics .HasError () {
12841305 return
@@ -1384,9 +1405,6 @@ func mapFields(ctx context.Context, r *observability.GetInstanceResponse, model
13841405 model .GrafanaPublicReadAccess = types .BoolPointerValue (i .GrafanaPublicReadAccess )
13851406 model .GrafanaInitialAdminPassword = types .StringPointerValue (i .GrafanaAdminPassword )
13861407 model .GrafanaInitialAdminUser = types .StringPointerValue (i .GrafanaAdminUser )
1387- model .MetricsRetentionDays = types .Int64Value (int64 (* i .MetricsRetentionTimeRaw ))
1388- model .MetricsRetentionDays5mDownsampling = types .Int64Value (int64 (* i .MetricsRetentionTime5m ))
1389- model .MetricsRetentionDays1hDownsampling = types .Int64Value (int64 (* i .MetricsRetentionTime1h ))
13901408 model .MetricsURL = types .StringPointerValue (i .MetricsUrl )
13911409 model .MetricsPushURL = types .StringPointerValue (i .PushMetricsUrl )
13921410 model .TargetsURL = types .StringPointerValue (i .TargetsUrl )
@@ -2236,17 +2254,17 @@ func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
22362254 return nil
22372255}
22382256
2239- func setACL (ctx context.Context , state tfsdk.State , model * Model ) diag.Diagnostics {
2257+ func setACL (ctx context.Context , state * tfsdk.State , model * Model ) diag.Diagnostics {
22402258 return state .SetAttribute (ctx , path .Root ("acl" ), model .ACL )
22412259}
22422260
2243- func setMetricsRetentions (ctx context.Context , state tfsdk.State , model * Model ) (diags diag.Diagnostics ) {
2261+ func setMetricsRetentions (ctx context.Context , state * tfsdk.State , model * Model ) (diags diag.Diagnostics ) {
22442262 diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days" ), model .MetricsRetentionDays )... )
22452263 diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days_5m_downsampling" ), model .MetricsRetentionDays5mDownsampling )... )
22462264 diags = append (diags , state .SetAttribute (ctx , path .Root ("metrics_retention_days_1h_downsampling" ), model .MetricsRetentionDays1hDownsampling )... )
22472265 return diags
22482266}
22492267
2250- func setAlertConfig (ctx context.Context , state tfsdk.State , model * Model ) diag.Diagnostics {
2268+ func setAlertConfig (ctx context.Context , state * tfsdk.State , model * Model ) diag.Diagnostics {
22512269 return state .SetAttribute (ctx , path .Root ("alert_config" ), model .AlertConfig )
22522270}
0 commit comments