feat(modifiers): add UnchangedPaths - #1707
Open
cgoetz-inovex wants to merge 2 commits into
Open
Conversation
- delete unused Int64Unchanged (cherry picked from commit 4de5802)
Comment on lines
+123
to
+125
| if !stateValue.Equal(planValue) { | ||
| allUnchanged = false | ||
| } |
Contributor
There was a problem hiding this comment.
Maybe we can do a early return here? No need to keep walking the other paths when at least one is changed
Comment on lines
+314
to
+318
| name: "no wildcard matches", | ||
| paths: []path.Expression{allItemValues}, | ||
| plan: testValues{anchor: "new", items: []string{}}, | ||
| state: testValues{anchor: "old", items: []string{}}, | ||
| want: true, |
Contributor
There was a problem hiding this comment.
Not sure about this behavior. I think users of the function might silently introduce bugs when this function returns true if i pass a non-existing path on accident. Shouldnt we maybe rather throw an error in that case?
Contributor
Author
There was a problem hiding this comment.
The path exists here:
// state:
"items":tftypes.List[tftypes.Object["value":tftypes.String]]<>,
// plan:
"items":tftypes.List[tftypes.Object["value":tftypes.String]]<>
It's an empty list in both state and plan.
My assumption would be, that an empty list in plan and state qualifies as unchanged.
adding:
if len(matched) == 0 {
resp.Diagnostics.AddError(
"no matches", "foo")
return
}in the implementation would fail this empty list case here.
Completely non-existing paths are covered by the next case "invalid path".
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.
(cherry picked from commit 4de5802)
Description
relates to #1234
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)