Implement UseStateForUnknownIf plan modifier#1216
Open
ChihweiLHBird wants to merge 5 commits intohashicorp:mainfrom
Open
Implement UseStateForUnknownIf plan modifier#1216ChihweiLHBird wants to merge 5 commits intohashicorp:mainfrom
UseStateForUnknownIf plan modifier#1216ChihweiLHBird wants to merge 5 commits intohashicorp:mainfrom
Conversation
Signed-off-by: Zhiwei Liang <zhiwei.liang27@pm.me>
a4585e0 to
bd20dea
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements the UseStateForUnknownIf plan modifier across all Terraform attribute types, enabling conditional preservation of state values when plan values are unknown.
Changes:
- Adds
UseStateForUnknownIfplan modifier for 12 attribute types (string, bool, int32, int64, float32, float64, number, dynamic, list, map, set, object) - Includes conditional function types and response structures for each type
- Provides comprehensive test coverage with 6 test cases per type
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| resource/schema/stringplanmodifier/use_state_for_unknown_if.go | Implements conditional plan modifier for string type |
| resource/schema/stringplanmodifier/use_state_for_unknown_if_func.go | Defines conditional function type and response for string type |
| resource/schema/stringplanmodifier/use_state_for_unknown_if_test.go | Tests for string type plan modifier |
| resource/schema/boolplanmodifier/* | Same pattern for bool type |
| resource/schema/int32planmodifier/* | Same pattern for int32 type |
| resource/schema/int64planmodifier/* | Same pattern for int64 type |
| resource/schema/float32planmodifier/* | Same pattern for float32 type |
| resource/schema/float64planmodifier/* | Same pattern for float64 type |
| resource/schema/numberplanmodifier/* | Same pattern for number type |
| resource/schema/dynamicplanmodifier/* | Same pattern for dynamic type |
| resource/schema/listplanmodifier/* | Same pattern for list type |
| resource/schema/mapplanmodifier/* | Same pattern for map type |
| resource/schema/setplanmodifier/* | Same pattern for set type |
| resource/schema/objectplanmodifier/* | Same pattern for object type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
1fa0637 to
2a9240f
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Fixes #1214
Description
The
UseStateForUnknownIfplan modifier can copy the state value into plan when the condition is met.There are some common cases to use this plan modifier, for example: