mirror of https://github.com/k3s-io/k3s
remove useless codec param from strategicPatchObject
parent
0e097af8d8
commit
43baa697aa
|
@ -301,7 +301,7 @@ func (p *smpPatcher) applyPatchToCurrentObject(currentObject runtime.Object) (ru
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := strategicPatchObject(p.codec, p.defaulter, currentVersionedObject, p.patchJS, versionedObjToUpdate, p.schemaReferenceObj); err != nil {
|
||||
if err := strategicPatchObject(p.defaulter, currentVersionedObject, p.patchJS, versionedObjToUpdate, p.schemaReferenceObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Convert the object back to unversioned (aka internal version).
|
||||
|
@ -319,7 +319,6 @@ func (p *smpPatcher) applyPatchToCurrentObject(currentObject runtime.Object) (ru
|
|||
// <originalObject> and <patchJS>.
|
||||
// NOTE: Both <originalObject> and <objToUpdate> are supposed to be versioned.
|
||||
func strategicPatchObject(
|
||||
codec runtime.Codec,
|
||||
defaulter runtime.ObjectDefaulter,
|
||||
originalObject runtime.Object,
|
||||
patchJS []byte,
|
||||
|
@ -336,7 +335,7 @@ func strategicPatchObject(
|
|||
return errors.NewBadRequest(err.Error())
|
||||
}
|
||||
|
||||
if err := applyPatchToObject(codec, defaulter, originalObjMap, patchMap, objToUpdate, schemaReferenceObj); err != nil {
|
||||
if err := applyPatchToObject(defaulter, originalObjMap, patchMap, objToUpdate, schemaReferenceObj); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -396,7 +395,6 @@ func (p *patcher) patchResource(ctx context.Context) (runtime.Object, error) {
|
|||
// <originalMap> and stores the result in <objToUpdate>.
|
||||
// NOTE: <objToUpdate> must be a versioned object.
|
||||
func applyPatchToObject(
|
||||
codec runtime.Codec,
|
||||
defaulter runtime.ObjectDefaulter,
|
||||
originalMap map[string]interface{},
|
||||
patchMap map[string]interface{},
|
||||
|
|
|
@ -79,7 +79,6 @@ func (obj *testPatchType) DeepCopyObject() runtime.Object {
|
|||
func TestPatchAnonymousField(t *testing.T) {
|
||||
testGV := schema.GroupVersion{Group: "", Version: "v"}
|
||||
scheme.AddKnownTypes(testGV, &testPatchType{})
|
||||
codec := codecs.LegacyCodec(testGV)
|
||||
defaulter := runtime.ObjectDefaulter(scheme)
|
||||
|
||||
original := &testPatchType{
|
||||
|
@ -93,7 +92,7 @@ func TestPatchAnonymousField(t *testing.T) {
|
|||
}
|
||||
|
||||
actual := &testPatchType{}
|
||||
err := strategicPatchObject(codec, defaulter, original, []byte(patch), actual, &testPatchType{})
|
||||
err := strategicPatchObject(defaulter, original, []byte(patch), actual, &testPatchType{})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
@ -105,7 +104,6 @@ func TestPatchAnonymousField(t *testing.T) {
|
|||
func TestPatchInvalid(t *testing.T) {
|
||||
testGV := schema.GroupVersion{Group: "", Version: "v"}
|
||||
scheme.AddKnownTypes(testGV, &testPatchType{})
|
||||
codec := codecs.LegacyCodec(testGV)
|
||||
defaulter := runtime.ObjectDefaulter(scheme)
|
||||
|
||||
original := &testPatchType{
|
||||
|
@ -116,7 +114,7 @@ func TestPatchInvalid(t *testing.T) {
|
|||
expectedError := "invalid character 'b' looking for beginning of value"
|
||||
|
||||
actual := &testPatchType{}
|
||||
err := strategicPatchObject(codec, defaulter, original, []byte(patch), actual, &testPatchType{})
|
||||
err := strategicPatchObject(defaulter, original, []byte(patch), actual, &testPatchType{})
|
||||
if !apierrors.IsBadRequest(err) {
|
||||
t.Errorf("expected HTTP status: BadRequest, got: %#v", apierrors.ReasonForError(err))
|
||||
}
|
||||
|
@ -128,7 +126,6 @@ func TestPatchInvalid(t *testing.T) {
|
|||
func TestPatchCustomResource(t *testing.T) {
|
||||
testGV := schema.GroupVersion{Group: "mygroup.example.com", Version: "v1beta1"}
|
||||
scheme.AddKnownTypes(testGV, &unstructured.Unstructured{})
|
||||
codec := codecs.LegacyCodec(testGV)
|
||||
defaulter := runtime.ObjectDefaulter(scheme)
|
||||
|
||||
original := &unstructured.Unstructured{
|
||||
|
@ -148,7 +145,7 @@ func TestPatchCustomResource(t *testing.T) {
|
|||
expectedError := "strategic merge patch format is not supported"
|
||||
|
||||
actual := &unstructured.Unstructured{}
|
||||
err := strategicPatchObject(codec, defaulter, original, []byte(patch), actual, &unstructured.Unstructured{})
|
||||
err := strategicPatchObject(defaulter, original, []byte(patch), actual, &unstructured.Unstructured{})
|
||||
if !apierrors.IsBadRequest(err) {
|
||||
t.Errorf("expected HTTP status: BadRequest, got: %#v", apierrors.ReasonForError(err))
|
||||
}
|
||||
|
@ -453,7 +450,6 @@ func (tc *patchTestCase) Run(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNumberConversion(t *testing.T) {
|
||||
codec := codecs.LegacyCodec(examplev1.SchemeGroupVersion)
|
||||
defaulter := runtime.ObjectDefaulter(scheme)
|
||||
|
||||
terminationGracePeriodSeconds := int64(42)
|
||||
|
@ -471,7 +467,7 @@ func TestNumberConversion(t *testing.T) {
|
|||
|
||||
patchJS := []byte(`{"spec":{"terminationGracePeriodSeconds":42,"activeDeadlineSeconds":120}}`)
|
||||
|
||||
err := strategicPatchObject(codec, defaulter, currentVersionedObject, patchJS, versionedObjToUpdate, schemaReferenceObj)
|
||||
err := strategicPatchObject(defaulter, currentVersionedObject, patchJS, versionedObjToUpdate, schemaReferenceObj)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue