@@ -12,7 +12,6 @@ import (
1212 "github.com/hashicorp/terraform-plugin-framework/path"
1313 "github.com/hashicorp/terraform-plugin-framework/resource"
1414 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
15- "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
1615 "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1716 "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1817 "github.com/hashicorp/terraform-plugin-framework/types"
@@ -114,22 +113,24 @@ func (r *SolutionResource) Schema(ctx context.Context, req resource.SchemaReques
114113 MarkdownDescription : "Display name of the solution" ,
115114 Description : "Display name of the solution" ,
116115 Computed : true ,
116+ PlanModifiers : []planmodifier.String {
117+ powerplatform_modifiers .SetStringValueToUnknownIfChecksumsChangeModifier ([]string {"solution_file" , "solution_file_checksum" }, []string {"settings_file" , "settings_file_checksum" }),
118+ },
117119 },
118120 "is_managed" : schema.BoolAttribute {
119121 MarkdownDescription : "Indicates whether the solution is managed or not" ,
120122 Description : "Indicates whether the solution is managed or not" ,
121123 Computed : true ,
122124 PlanModifiers : []planmodifier.Bool {
123- boolplanmodifier . UseStateForUnknown ( ),
125+ powerplatform_modifiers . SetBoolValueToUnknownIfChecksumsChangeModifier ([] string { "solution_file" , "solution_file_checksum" }, [] string { "settings_file" , "settings_file_checksum" } ),
124126 },
125127 },
126-
127128 "solution_version" : schema.StringAttribute {
128129 MarkdownDescription : "Version of the solution" ,
129130 Description : "Version of the solution" ,
130131 Computed : true ,
131132 PlanModifiers : []planmodifier.String {
132- stringplanmodifier . UseStateForUnknown ( ),
133+ powerplatform_modifiers . SetStringValueToUnknownIfChecksumsChangeModifier ([] string { "solution_file" , "solution_file_checksum" }, [] string { "settings_file" , "settings_file_checksum" } ),
133134 },
134135 },
135136 },
@@ -178,7 +179,7 @@ func (r *SolutionResource) Create(ctx context.Context, req resource.CreateReques
178179 plan .DisplayName = types .StringValue (solution .DisplayName )
179180 plan .Id = types .StringValue (fmt .Sprintf ("%s_%s" , plan .EnvironmentId .ValueString (), solution .Name ))
180181
181- plan .SettingsFileChecksum = types .StringUnknown ()
182+ plan .SettingsFileChecksum = types .StringNull ()
182183 if ! plan .SettingsFile .IsNull () && ! plan .SettingsFile .IsUnknown () {
183184 value , err := powerplatform_helpers .CalculateMd5 (plan .SettingsFile .ValueString ())
184185 if err != nil {
@@ -187,8 +188,6 @@ func (r *SolutionResource) Create(ctx context.Context, req resource.CreateReques
187188 plan .SettingsFileChecksum = types .StringValue (value )
188189 tflog .Warn (ctx , fmt .Sprintf ("CREATE Calculated md5 hash of settings file: %s" , value ))
189190 }
190- } else {
191- plan .SettingsFileChecksum = types .StringNull ()
192191 }
193192
194193 plan .SolutionFileChecksum = types .StringUnknown ()
@@ -233,7 +232,6 @@ func (r *SolutionResource) Read(ctx context.Context, req resource.ReadRequest, r
233232 if solution .Name == state .SolutionName .ValueString () {
234233 state .Id = types .StringValue (fmt .Sprintf ("%s_%s" , state .EnvironmentId .ValueString (), solution .Name ))
235234 state .SolutionName = types .StringValue (solution .Name )
236- //TODO test a case when solution version changes
237235 state .SolutionVersion = types .StringValue (solution .Version )
238236 state .IsManaged = types .BoolValue (solution .IsManaged )
239237 state .DisplayName = types .StringValue (solution .DisplayName )
@@ -316,6 +314,9 @@ func (r *SolutionResource) Update(ctx context.Context, req resource.UpdateReques
316314 }
317315
318316 solution := r .importSolution (ctx , plan , & resp .Diagnostics )
317+ if resp .Diagnostics .HasError () {
318+ return
319+ }
319320
320321 plan .Id = types .StringValue (fmt .Sprintf ("%s_%s" , plan .EnvironmentId .ValueString (), solution .Name ))
321322
@@ -324,7 +325,7 @@ func (r *SolutionResource) Update(ctx context.Context, req resource.UpdateReques
324325 plan .IsManaged = types .BoolValue (solution .IsManaged )
325326 plan .DisplayName = types .StringValue (solution .DisplayName )
326327
327- plan .SettingsFileChecksum = types .StringUnknown ()
328+ plan .SettingsFileChecksum = types .StringNull ()
328329 if ! plan .SettingsFile .IsNull () && ! plan .SettingsFile .IsUnknown () {
329330 value , err := powerplatform_helpers .CalculateMd5 (plan .SettingsFile .ValueString ())
330331 if err != nil {
0 commit comments