Skip to content

Commit c57799f

Browse files
Remove experimental flag for SkipDetailedDiff (#1893)
Removes the flag option `XSkipDetailedDiffForChanges` and rolls out behavior to all providers. This change will break the next bridge release for pulumi-gcp and pulumi-aws. When updating those providers to these changes, the `XSkipDetailedDiffForChanges` provider info option must be removed. Note that the maxItemsOne migration tests needed to be updated to show that a change of `[]` to `""` reflects a diff on the field in question now. This makes sense to me, since a nil slice is different from an empty string, but this may actually not be desired behavior, so I'd appreciate scrutiny here. Either way, the functionality under test there requires a diff to happen on MaxItemsOne migrations and that does not change. Fixes #1501.
2 parents e71c1a6 + 682a19a commit c57799f

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

pkg/tfbridge/diff_test.go

+8-11
Original file line numberDiff line numberDiff line change
@@ -2071,14 +2071,13 @@ func TestListNestedAddMaxItemsOne(t *testing.T) {
20712071
}
20722072

20732073
type diffTestCase struct {
2074-
resourceSchema map[string]*schema.Schema
2075-
resourceFields map[string]*SchemaInfo
2076-
state resource.PropertyMap
2077-
inputs resource.PropertyMap
2078-
expected map[string]*pulumirpc.PropertyDiff
2079-
expectedDiffChanges pulumirpc.DiffResponse_DiffChanges
2080-
ignoreChanges []string
2081-
XSkipDetailedDiffForChanges bool
2074+
resourceSchema map[string]*schema.Schema
2075+
resourceFields map[string]*SchemaInfo
2076+
state resource.PropertyMap
2077+
inputs resource.PropertyMap
2078+
expected map[string]*pulumirpc.PropertyDiff
2079+
expectedDiffChanges pulumirpc.DiffResponse_DiffChanges
2080+
ignoreChanges []string
20822081
}
20832082

20842083
func diffTest2(t *testing.T, tc diffTestCase) {
@@ -2100,7 +2099,6 @@ func diffTest2(t *testing.T, tc diffTestCase) {
21002099
p := Provider{
21012100
tf: provider,
21022101
info: ProviderInfo{
2103-
XSkipDetailedDiffForChanges: tc.XSkipDetailedDiffForChanges,
21042102
Resources: map[string]*ResourceInfo{
21052103
"p_resource": {
21062104
Tok: "pkg:index:PResource",
@@ -2151,8 +2149,7 @@ func TestChangingMaxItems1FilterProperty(t *testing.T) {
21512149
},
21522150
}
21532151
diffTest2(t, diffTestCase{
2154-
XSkipDetailedDiffForChanges: true,
2155-
resourceSchema: schema,
2152+
resourceSchema: schema,
21562153
state: resource.PropertyMap{
21572154
"rules": resource.NewArrayProperty(
21582155
[]resource.PropertyValue{

pkg/tfbridge/info/info.go

-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ type Provider struct {
151151
// See also: pulumi/pulumi-terraform-bridge#1448
152152
SkipValidateProviderConfigForPluginFramework bool
153153

154-
// Disables using detailed diff to determine diff changes and falls back on the length of TF Diff Attributes.
155-
//
156-
// See https://github.com/pulumi/pulumi-terraform-bridge/issues/1501
157-
XSkipDetailedDiffForChanges bool
158-
159154
// Enables generation of a trimmed, runtime-only metadata file
160155
// to help reduce resource plugin start time
161156
//

pkg/tfbridge/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ func (p *Provider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulum
926926
// We will still use `detailedDiff` for diff display purposes.
927927

928928
// See also https://github.com/pulumi/pulumi-terraform-bridge/issues/1501.
929-
if p.info.XSkipDetailedDiffForChanges && len(diff.Attributes()) > 0 {
929+
if len(diff.Attributes()) > 0 {
930930
changes = pulumirpc.DiffResponse_DIFF_SOME
931931
// Perhaps collectionDiffs can shed some light and locate the changes to the end-user.
932932
for path, diff := range dd.collectionDiffs {

pkg/tfbridge/provider_test.go

+27-4
Original file line numberDiff line numberDiff line change
@@ -2156,9 +2156,6 @@ func TestSkipDetailedDiff(t *testing.T) {
21562156
Schema: &ResourceInfo{Tok: "Replace"},
21572157
},
21582158
},
2159-
info: ProviderInfo{
2160-
XSkipDetailedDiffForChanges: skipDetailedDiffForChanges,
2161-
},
21622159
}
21632160
}
21642161
t.Run("Diff", func(t *testing.T) {
@@ -2432,7 +2429,7 @@ func TestMaxItemOneWrongStateDiff(t *testing.T) {
24322429
"urn": "urn:pulumi:dev::teststack::NestedStrRes::exres",
24332430
"id": "0",
24342431
"olds": {
2435-
"nested_str": []
2432+
"nested_str": [""]
24362433
},
24372434
"news": {
24382435
"nested_str": ""
@@ -2444,6 +2441,32 @@ func TestMaxItemOneWrongStateDiff(t *testing.T) {
24442441
}
24452442
}`)
24462443
})
2444+
t.Run("DiffNilListAndVal", func(t *testing.T) {
2445+
testutils.Replay(t, provider, `
2446+
{
2447+
"method": "/pulumirpc.ResourceProvider/Diff",
2448+
"request": {
2449+
"urn": "urn:pulumi:dev::teststack::NestedStrRes::exres",
2450+
"id": "0",
2451+
"olds": {
2452+
"nested_str": []
2453+
},
2454+
"news": {
2455+
"nested_str": ""
2456+
}
2457+
},
2458+
"response": {
2459+
"changes": "DIFF_SOME",
2460+
"hasDetailedDiff": true,
2461+
"detailedDiff": {
2462+
"nested_str": {
2463+
"kind": "UPDATE"
2464+
}
2465+
},
2466+
"diffs": ["nested_str"]
2467+
}
2468+
}`)
2469+
})
24472470
t.Run("DiffListAndValNonEmpty", func(t *testing.T) {
24482471
testutils.Replay(t, provider, `
24492472
{

0 commit comments

Comments
 (0)