Merge pull request #132499 from liggitt/unwanted-json-patch-v5

Add json-patch v4 compatibility test
This commit is contained in:
Kubernetes Prow Robot
2025-06-24 09:54:35 -07:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
"github.com/bketelsen/crypt": "unused, crypto",
"github.com/containerd/cgroups": "standardize on single cgroups library from runc, refer #128157",
"github.com/davecgh/go-spew": "refer to #103942",
"github.com/evanphx/json-patch/v5": "refer to https://github.com/kubernetes/kubernetes/pull/91622#issuecomment-637087847",
"github.com/form3tech-oss/jwt-go": "unmaintained, archive mode",
"github.com/getsentry/raven-go": "unmaintained, archive mode",
"github.com/go-bindata/go-bindata": "refer to #99829",

View File

@@ -29,6 +29,7 @@ import (
"github.com/google/go-cmp/cmp"
jsonpatch "gopkg.in/evanphx/json-patch.v4"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -249,6 +250,15 @@ func TestJSONPatch(t *testing.T) {
name: "valid-negative-index-patch",
patch: `[{"op": "test", "value": "foo", "path": "/metadata/finalizers/-1"}]`,
},
// This demonstrates out-of-spec behavior json-patch v4 allows,
// which Kubernetes clients may depend on, and which updating to json-patch v5 currently breaks
{
name: "replace-missing-path-allowed",
patch: `[
{"op":"replace", "path":"/metadata/path", "value":"foo"},
{"op":"test", "path":"/metadata/path", "value":"foo"}
]`,
},
} {
p := &patcher{
patchType: types.JSONPatchType,