-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't force resource replacement when expiration is unset during SDK-…
…PF migratino
- Loading branch information
Showing
5 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package api_key | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/elastic/terraform-provider-elasticstack/internal/utils" | ||
"github.com/hashicorp/terraform-plugin-framework/resource" | ||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes" | ||
) | ||
|
||
func (r *Resource) UpgradeState(context.Context) map[int64]resource.StateUpgrader { | ||
return map[int64]resource.StateUpgrader{ | ||
0: { | ||
PriorSchema: utils.Pointer(r.getSchema(0)), | ||
StateUpgrader: func(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { | ||
var model tfModel | ||
resp.Diagnostics.Append(req.State.Get(ctx, &model)...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
if utils.IsKnown(model.Expiration) && model.Expiration.ValueString() == "" { | ||
model.Expiration = basetypes.NewStringNull() | ||
} | ||
|
||
resp.State.Set(ctx, model) | ||
}, | ||
}, | ||
} | ||
} |