@@ -118,7 +118,7 @@ func (r *credentialResource) modifyPlanExpiration(ctx context.Context, req *reso
118118 // replace the planned expiration time with the current state date, iff they represent
119119 // the same point in time (but perhaps with different textual representation)
120120 // this will prevent no-op updates
121- if stateDate .Equal (planDate ) {
121+ if stateDate .Equal (planDate ) && ! stateDate . IsZero () {
122122 resp .Diagnostics .Append (resp .Plan .SetAttribute (ctx , p , types .StringValue (stateDate .Format (time .RFC3339 )))... )
123123 if resp .Diagnostics .HasError () {
124124 return
@@ -307,22 +307,24 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
307307 return
308308 }
309309
310- var (
311- actualDate time.Time
312- planDate time.Time
313- )
314- resp .Diagnostics .Append (utils .ToTime (ctx , time .RFC3339 , model .ExpirationTimestamp , & actualDate )... )
315- if resp .Diagnostics .HasError () {
316- return
317- }
318- resp .Diagnostics .Append (utils .GetTimeFromStringAttribute (ctx , path .Root ("expiration_timestamp" ), req .Plan , time .RFC3339 , & planDate )... )
319- if resp .Diagnostics .HasError () {
320- return
321- }
322- // replace the planned expiration date with the original date, iff
323- // they represent the same point in time, (perhaps with different textual representations)
324- if actualDate .Equal (planDate ) {
325- model .ExpirationTimestamp = types .StringValue (planDate .Format (time .RFC3339 ))
310+ if ! utils .IsUndefined (model .ExpirationTimestamp ) {
311+ var (
312+ actualDate time.Time
313+ planDate time.Time
314+ )
315+ resp .Diagnostics .Append (utils .ToTime (ctx , time .RFC3339 , model .ExpirationTimestamp , & actualDate )... )
316+ if resp .Diagnostics .HasError () {
317+ return
318+ }
319+ resp .Diagnostics .Append (utils .GetTimeFromStringAttribute (ctx , path .Root ("expiration_timestamp" ), req .Plan , time .RFC3339 , & planDate )... )
320+ if resp .Diagnostics .HasError () {
321+ return
322+ }
323+ // replace the planned expiration date with the original date, iff
324+ // they represent the same point in time, (perhaps with different textual representations)
325+ if actualDate .Equal (planDate ) {
326+ model .ExpirationTimestamp = types .StringValue (planDate .Format (time .RFC3339 ))
327+ }
326328 }
327329
328330 diags = resp .State .Set (ctx , model )
@@ -369,20 +371,22 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
369371 stateDate time.Time
370372 )
371373
372- resp .Diagnostics .Append (utils .ToTime (ctx , time .RFC3339 , model .ExpirationTimestamp , & currentApiDate )... )
373- if resp .Diagnostics .HasError () {
374- return
375- }
374+ if ! utils .IsUndefined (model .ExpirationTimestamp ) {
375+ resp .Diagnostics .Append (utils .ToTime (ctx , time .RFC3339 , model .ExpirationTimestamp , & currentApiDate )... )
376+ if resp .Diagnostics .HasError () {
377+ return
378+ }
376379
377- resp .Diagnostics .Append (utils .GetTimeFromStringAttribute (ctx , path .Root ("expiration_timestamp" ), req .State , time .RFC3339 , & stateDate )... )
378- if resp .Diagnostics .HasError () {
379- return
380- }
380+ resp .Diagnostics .Append (utils .GetTimeFromStringAttribute (ctx , path .Root ("expiration_timestamp" ), req .State , time .RFC3339 , & stateDate )... )
381+ if resp .Diagnostics .HasError () {
382+ return
383+ }
381384
382- // replace the resulting expiration date with the original date, iff
383- // they represent the same point in time, (perhaps with different textual representations)
384- if currentApiDate .Equal (stateDate ) {
385- model .ExpirationTimestamp = types .StringValue (stateDate .Format (time .RFC3339 ))
385+ // replace the resulting expiration date with the original date, iff
386+ // they represent the same point in time, (perhaps with different textual representations)
387+ if currentApiDate .Equal (stateDate ) {
388+ model .ExpirationTimestamp = types .StringValue (stateDate .Format (time .RFC3339 ))
389+ }
386390 }
387391
388392 // Set refreshed state
0 commit comments