Skip to content

Commit 9ba447f

Browse files
committed
CreateMergePatchFromStrings' no longer used.
1 parent e5605cc commit 9ba447f

File tree

5 files changed

+4
-81
lines changed

5 files changed

+4
-81
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ require (
276276
github.com/cedar-policy/cedar-go v1.2.6
277277
github.com/davecgh/go-spew v1.1.1
278278
github.com/dlclark/regexp2 v1.11.5
279-
github.com/evanphx/json-patch v0.5.2
280279
github.com/gertd/go-pluralize v0.2.1
281280
github.com/goccy/go-yaml v1.18.0
282281
github.com/google/go-cmp v0.7.0
@@ -338,6 +337,7 @@ require (
338337
github.com/bgentry/speakeasy v0.1.0 // indirect
339338
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
340339
github.com/cloudflare/circl v1.6.1 // indirect
340+
github.com/evanphx/json-patch v0.5.2 // indirect
341341
github.com/fatih/color v1.18.0 // indirect
342342
github.com/go-logr/logr v1.4.3 // indirect
343343
github.com/go-logr/stdr v1.2.2 // indirect
@@ -360,7 +360,6 @@ require (
360360
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
361361
github.com/mitchellh/reflectwalk v1.0.2 // indirect
362362
github.com/oklog/run v1.0.0 // indirect
363-
github.com/pkg/errors v0.9.1 // indirect
364363
github.com/posener/complete v1.2.3 // indirect
365364
github.com/spf13/cast v1.3.1 // indirect
366365
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect

internal/json/patch.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package json
55

66
import (
7-
evanphxjsonpatch "github.com/evanphx/json-patch"
87
mattbairdjsonpatch "github.com/mattbaird/jsonpatch"
98
)
109

@@ -14,15 +13,3 @@ import (
1413
func CreatePatchFromStrings(a, b string) ([]mattbairdjsonpatch.JsonPatchOperation, error) {
1514
return mattbairdjsonpatch.CreatePatch([]byte(a), []byte(b))
1615
}
17-
18-
// `CreateMergePatchFromStrings` creates an [RFC7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch from two JSON strings.
19-
// `a` is the original JSON document and `b` is the modified JSON document.
20-
// The patch is returned as a JSON string.
21-
func CreateMergePatchFromStrings(a, b string) (string, error) {
22-
patch, err := evanphxjsonpatch.CreateMergePatch([]byte(a), []byte(b))
23-
if err != nil {
24-
return "", err
25-
}
26-
27-
return string(patch), nil
28-
}

internal/json/patch_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88

99
"github.com/google/go-cmp/cmp"
10-
"github.com/hashicorp/terraform-provider-aws/internal/acctest/jsoncmp"
1110
tfjson "github.com/hashicorp/terraform-provider-aws/internal/json"
1211
mattbairdjsonpatch "github.com/mattbaird/jsonpatch"
1312
)
@@ -84,67 +83,3 @@ func TestCreatePatchFromStrings(t *testing.T) {
8483
})
8584
}
8685
}
87-
88-
func TestCreateMergePatchFromStrings(t *testing.T) {
89-
t.Parallel()
90-
91-
testCases := []struct {
92-
testName string
93-
a, b string
94-
wantPatch string
95-
wantErr bool
96-
}{
97-
{
98-
testName: "invalid JSON",
99-
a: `test`,
100-
b: `{}`,
101-
wantErr: true,
102-
},
103-
{
104-
testName: "empty patch, empty JSON",
105-
a: `{}`,
106-
b: `{}`,
107-
wantPatch: `{}`,
108-
},
109-
{
110-
testName: "empty patch, non-empty JSON",
111-
a: `{"A": "test1", "B": 42}`,
112-
b: `{"B": 42, "A": "test1"}`,
113-
wantPatch: `{}`,
114-
},
115-
{
116-
testName: "from empty JSON",
117-
a: `{}`,
118-
b: `{"A": "test1", "B": 42}`,
119-
wantPatch: `{"A":"test1", "B":42}`,
120-
},
121-
{
122-
testName: "to empty JSON",
123-
a: `{"A": "test1", "B": 42}`,
124-
b: `{}`,
125-
wantPatch: `{"A":null, "B":null}`,
126-
},
127-
{
128-
testName: "change values",
129-
a: `{"A": "test1", "B": 42}`,
130-
b: `{"A": ["test2"], "B": 42}`,
131-
wantPatch: `{"A": ["test2"]}`,
132-
},
133-
}
134-
135-
for _, testCase := range testCases {
136-
t.Run(testCase.testName, func(t *testing.T) {
137-
t.Parallel()
138-
139-
got, err := tfjson.CreateMergePatchFromStrings(testCase.a, testCase.b)
140-
if got, want := err != nil, testCase.wantErr; !cmp.Equal(got, want) {
141-
t.Errorf("CreateMergePatchFromStrings(%s, %s) err %t, want %t", testCase.a, testCase.b, got, want)
142-
}
143-
if err == nil {
144-
if diff := jsoncmp.Diff(got, testCase.wantPatch); diff != "" {
145-
t.Errorf("unexpected diff (+wanted, -got): %s", diff)
146-
}
147-
}
148-
})
149-
}
150-
}

tools/tfsdk2fw/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ require (
285285
github.com/aws/aws-sdk-go-v2/service/wafregional v1.30.2 // indirect
286286
github.com/aws/aws-sdk-go-v2/service/wafv2 v1.67.2 // indirect
287287
github.com/aws/aws-sdk-go-v2/service/wellarchitected v1.39.2 // indirect
288+
github.com/aws/aws-sdk-go-v2/service/workmail v1.36.0 // indirect
288289
github.com/aws/aws-sdk-go-v2/service/workspaces v1.63.2 // indirect
289290
github.com/aws/aws-sdk-go-v2/service/workspacesweb v1.32.2 // indirect
290291
github.com/aws/aws-sdk-go-v2/service/xray v1.36.0 // indirect
@@ -345,7 +346,6 @@ require (
345346
github.com/mitchellh/mapstructure v1.5.0 // indirect
346347
github.com/mitchellh/reflectwalk v1.0.2 // indirect
347348
github.com/oklog/run v1.0.0 // indirect
348-
github.com/pkg/errors v0.9.1 // indirect
349349
github.com/posener/complete v1.2.3 // indirect
350350
github.com/shopspring/decimal v1.4.0 // indirect
351351
github.com/spf13/cast v1.3.1 // indirect

tools/tfsdk2fw/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ github.com/aws/aws-sdk-go-v2/service/wafv2 v1.67.2 h1:2DlTie50vaR48vl7qfhwO4/Wcy
557557
github.com/aws/aws-sdk-go-v2/service/wafv2 v1.67.2/go.mod h1:AJoCa1C5NTIPrb+ipa37XCLmzJx8+yR0oR0RthAX3i0=
558558
github.com/aws/aws-sdk-go-v2/service/wellarchitected v1.39.2 h1:giFfWGLth/IiJZ3LgvG/hy6T8J4vbaB+X5K4MN0CX8I=
559559
github.com/aws/aws-sdk-go-v2/service/wellarchitected v1.39.2/go.mod h1:o/TFtOOoVM7yZX2qHtHd1i0UBGI49Wt0lTzauYbKEJc=
560+
github.com/aws/aws-sdk-go-v2/service/workmail v1.36.0 h1:n+zawjC5CTE4MJg+uBm8gJt1tEVoMX6zyZZpGV7DR2M=
561+
github.com/aws/aws-sdk-go-v2/service/workmail v1.36.0/go.mod h1:6CKjfL6oQH63mt1VFvewFsu4ySbRsCJ5UvPc/idWWvI=
560562
github.com/aws/aws-sdk-go-v2/service/workspaces v1.63.2 h1:b9rCSKtYt9bzjTKhvM9HJlSOkX9nrbvOM+Bx2OrLmD0=
561563
github.com/aws/aws-sdk-go-v2/service/workspaces v1.63.2/go.mod h1:cyuDqMRRIARXm/gndad2OF+XeXotAL349N6/hZympDY=
562564
github.com/aws/aws-sdk-go-v2/service/workspacesweb v1.32.2 h1:pEI+JZb/82WZpqO0dTxipiZeBCl6UhCYUkDDsFcxs5Q=

0 commit comments

Comments
 (0)