@@ -27,6 +27,8 @@ import (
27
27
28
28
"github.com/hashicorp/terraform-plugin-framework/resource"
29
29
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
30
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
31
+ "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
30
32
"github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier"
31
33
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
32
34
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
@@ -224,18 +226,30 @@ func (r *CachedImageResource) Schema(ctx context.Context, req resource.SchemaReq
224
226
ElementType : types .StringType ,
225
227
Computed : true ,
226
228
Sensitive : true ,
229
+ PlanModifiers : []planmodifier.List {
230
+ listplanmodifier .RequiresReplace (),
231
+ },
227
232
},
228
233
"exists" : schema.BoolAttribute {
229
234
MarkdownDescription : "Whether the cached image was exists or not for the given config." ,
230
235
Computed : true ,
236
+ PlanModifiers : []planmodifier.Bool {
237
+ boolplanmodifier .RequiresReplace (),
238
+ },
231
239
},
232
240
"id" : schema.StringAttribute {
233
241
MarkdownDescription : "Cached image identifier. This will generally be the image's SHA256 digest." ,
234
242
Computed : true ,
243
+ PlanModifiers : []planmodifier.String {
244
+ stringplanmodifier .RequiresReplace (),
245
+ },
235
246
},
236
247
"image" : schema.StringAttribute {
237
248
MarkdownDescription : "Outputs the cached image repo@digest if it exists, and builder image otherwise." ,
238
249
Computed : true ,
250
+ PlanModifiers : []planmodifier.String {
251
+ stringplanmodifier .RequiresReplace (),
252
+ },
239
253
},
240
254
},
241
255
}
@@ -273,6 +287,7 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
273
287
// If the previous state is that Image == BuilderImage, then we previously did
274
288
// not find the image. We will need to run another cache probe.
275
289
if data .Image .Equal (data .BuilderImage ) {
290
+ tflog .Debug (ctx , "Image previously not found. Recreating." , map [string ]any {"ref" : data .Image .ValueString ()})
276
291
resp .State .RemoveResource (ctx )
277
292
return
278
293
}
@@ -284,9 +299,9 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
284
299
resp .Diagnostics .AddError ("Error checking remote image" , err .Error ())
285
300
return
286
301
}
287
- tflog .Debug (ctx , "Remote image does not exist" , map [string ]any {"ref" : data .Image .ValueString ()})
288
302
// Image does not exist any longer! Remove the resource so we can re-create
289
303
// it next time.
304
+ tflog .Debug (ctx , "Remote image does not exist any longer. Recreating." , map [string ]any {"ref" : data .Image .ValueString ()})
290
305
resp .State .RemoveResource (ctx )
291
306
return
292
307
}
0 commit comments