Bump gomodules.xyz/jsonpatch/v2 from 2.4.0 to 2.5.0 (#3154)

* Bump gomodules.xyz/jsonpatch/v2 from 2.4.0 to 2.5.0

Bumps [gomodules.xyz/jsonpatch/v2](https://github.com/gomodules/jsonpatch) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/gomodules/jsonpatch/releases)
- [Changelog](https://github.com/gomodules/jsonpatch/blob/release-2.0/CHANGELOG.md)
- [Commits](https://github.com/gomodules/jsonpatch/compare/v2.4.0...v2.5.0)

---
updated-dependencies:
- dependency-name: gomodules.xyz/jsonpatch/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Run ./hack/update-codegen.sh

* fix patch unit test

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dave Protasowski <dprotaso@gmail.com>
This commit is contained in:
dependabot[bot] 2025-04-11 13:38:14 +00:00 committed by GitHub
parent 7b91ff1a36
commit a8e20d9db3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 11 deletions

View File

@ -161,7 +161,7 @@ func TestCreatePatch(t *testing.T) {
want: JSONPatch{{
Operation: "replace",
Path: "/status/patchable/field1",
Value: 13.0,
Value: json.Number("13"),
}},
}, {
name: "patch two fields",
@ -184,7 +184,7 @@ func TestCreatePatch(t *testing.T) {
want: JSONPatch{{
Operation: "replace",
Path: "/status/patchable/field1",
Value: 42.0,
Value: json.Number("42"),
}, {
Operation: "remove",
Path: "/status/patchable/field2",

2
go.mod
View File

@ -27,7 +27,7 @@ require (
golang.org/x/net v0.38.0
golang.org/x/sync v0.13.0
golang.org/x/tools v0.31.0
gomodules.xyz/jsonpatch/v2 v2.4.0
gomodules.xyz/jsonpatch/v2 v2.5.0
google.golang.org/grpc v1.71.1
google.golang.org/protobuf v1.36.6
gopkg.in/yaml.v3 v3.0.1

4
go.sum
View File

@ -593,8 +593,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0=
gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca h1:PupagGYwj8+I4ubCxcmcBRk3VlUWtTg5huQpZR9flmE=
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=

View File

@ -70,12 +70,14 @@ func CreatePatch(a, b []byte) ([]Operation, error) {
}
var aI interface{}
var bI interface{}
err := json.Unmarshal(a, &aI)
if err != nil {
aDec := json.NewDecoder(bytes.NewReader(a))
aDec.UseNumber()
if err := aDec.Decode(&aI); err != nil {
return nil, errBadJSONDoc
}
err = json.Unmarshal(b, &bI)
if err != nil {
bDec := json.NewDecoder(bytes.NewReader(b))
bDec.UseNumber()
if err := bDec.Decode(&bI); err != nil {
return nil, errBadJSONDoc
}
return handleValues(aI, bI, "", []Operation{})
@ -94,6 +96,11 @@ func matchesValue(av, bv interface{}) bool {
if ok && bt == at {
return true
}
case json.Number:
bt, ok := bv.(json.Number)
if ok && bt == at {
return true
}
case float64:
bt, ok := bv.(float64)
if ok && bt == at {
@ -212,7 +219,7 @@ func handleValues(av, bv interface{}, p string, patch []Operation) ([]Operation,
if err != nil {
return nil, err
}
case string, float64, bool:
case string, float64, bool, json.Number:
if !matchesValue(av, bv) {
patch = append(patch, NewOperation("replace", p, bv))
}

2
vendor/modules.txt vendored
View File

@ -313,7 +313,7 @@ golang.org/x/tools/internal/stdlib
golang.org/x/tools/internal/typeparams
golang.org/x/tools/internal/typesinternal
golang.org/x/tools/internal/versions
# gomodules.xyz/jsonpatch/v2 v2.4.0
# gomodules.xyz/jsonpatch/v2 v2.5.0
## explicit; go 1.20
gomodules.xyz/jsonpatch/v2
# google.golang.org/api v0.183.0