@@ -19,7 +19,6 @@ package fake
19
19
import (
20
20
"bytes"
21
21
"context"
22
- "encoding/json"
23
22
"errors"
24
23
"fmt"
25
24
"reflect"
@@ -58,6 +57,7 @@ import (
58
57
"k8s.io/apimachinery/pkg/runtime"
59
58
"k8s.io/apimachinery/pkg/runtime/schema"
60
59
"k8s.io/apimachinery/pkg/types"
60
+ "k8s.io/apimachinery/pkg/util/json"
61
61
utilrand "k8s.io/apimachinery/pkg/util/rand"
62
62
"k8s.io/apimachinery/pkg/util/sets"
63
63
"k8s.io/apimachinery/pkg/util/strategicpatch"
@@ -66,7 +66,6 @@ import (
66
66
"k8s.io/client-go/kubernetes/scheme"
67
67
"k8s.io/client-go/testing"
68
68
"k8s.io/utils/ptr"
69
- kjson "sigs.k8s.io/json"
70
69
71
70
"sigs.k8s.io/controller-runtime/pkg/client"
72
71
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
@@ -378,7 +377,7 @@ func convertFromUnstructuredIfNecessary(s *runtime.Scheme, o runtime.Object) (ru
378
377
if err != nil {
379
378
return nil , fmt .Errorf ("failed to serialize %T: %w" , unstructuredSerialized , err )
380
379
}
381
- if err := kjson . UnmarshalCaseSensitivePreserveInts (unstructuredSerialized , typed ); err != nil {
380
+ if err := json . Unmarshal (unstructuredSerialized , typed ); err != nil {
382
381
return nil , fmt .Errorf ("failed to unmarshal the content of %T into %T: %w" , u , typed , err )
383
382
}
384
383
@@ -557,7 +556,7 @@ func (c *fakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.O
557
556
return err
558
557
}
559
558
zero (obj )
560
- return kjson . UnmarshalCaseSensitivePreserveInts (j , obj )
559
+ return json . Unmarshal (j , obj )
561
560
}
562
561
563
562
func (c * fakeClient ) Watch (ctx context.Context , list client.ObjectList , opts ... client.ListOption ) (watch.Interface , error ) {
@@ -621,7 +620,7 @@ func (c *fakeClient) List(ctx context.Context, obj client.ObjectList, opts ...cl
621
620
}
622
621
zero (obj )
623
622
objCopy := obj .DeepCopyObject ().(client.ObjectList )
624
- if err := kjson . UnmarshalCaseSensitivePreserveInts (j , objCopy ); err != nil {
623
+ if err := json . Unmarshal (j , objCopy ); err != nil {
625
624
return err
626
625
}
627
626
@@ -996,7 +995,7 @@ func (c *fakeClient) patch(obj client.Object, patch client.Patch, opts ...client
996
995
return err
997
996
}
998
997
zero (obj )
999
- return kjson . UnmarshalCaseSensitivePreserveInts (j , obj )
998
+ return json . Unmarshal (j , obj )
1000
999
}
1001
1000
1002
1001
// Applying a patch results in a deletionTimestamp that is truncated to the nearest second.
@@ -1048,7 +1047,7 @@ func dryPatch(action testing.PatchActionImpl, tracker testing.ObjectTracker) (ru
1048
1047
return nil , err
1049
1048
}
1050
1049
1051
- if err = kjson . UnmarshalCaseSensitivePreserveInts (modified , obj ); err != nil {
1050
+ if err = json . Unmarshal (modified , obj ); err != nil {
1052
1051
return nil , err
1053
1052
}
1054
1053
case types .MergePatchType :
@@ -1057,15 +1056,15 @@ func dryPatch(action testing.PatchActionImpl, tracker testing.ObjectTracker) (ru
1057
1056
return nil , err
1058
1057
}
1059
1058
1060
- if err := kjson . UnmarshalCaseSensitivePreserveInts (modified , obj ); err != nil {
1059
+ if err := json . Unmarshal (modified , obj ); err != nil {
1061
1060
return nil , err
1062
1061
}
1063
1062
case types .StrategicMergePatchType :
1064
1063
mergedByte , err := strategicpatch .StrategicMergePatch (old , action .GetPatch (), obj )
1065
1064
if err != nil {
1066
1065
return nil , err
1067
1066
}
1068
- if err = kjson . UnmarshalCaseSensitivePreserveInts (mergedByte , obj ); err != nil {
1067
+ if err = json . Unmarshal (mergedByte , obj ); err != nil {
1069
1068
return nil , err
1070
1069
}
1071
1070
case types .ApplyPatchType :
@@ -1122,7 +1121,7 @@ func toMapStringAny(obj runtime.Object) (map[string]any, error) {
1122
1121
}
1123
1122
1124
1123
u := map [string ]any {}
1125
- return u , kjson . UnmarshalCaseSensitivePreserveInts (serialized , & u )
1124
+ return u , json . Unmarshal (serialized , & u )
1126
1125
}
1127
1126
1128
1127
func fromMapStringAny (u map [string ]any , target runtime.Object ) error {
@@ -1137,7 +1136,7 @@ func fromMapStringAny(u map[string]any, target runtime.Object) error {
1137
1136
}
1138
1137
1139
1138
zero (target )
1140
- if err := kjson . UnmarshalCaseSensitivePreserveInts (serialized , & target ); err != nil {
1139
+ if err := json . Unmarshal (serialized , & target ); err != nil {
1141
1140
return fmt .Errorf ("failed to deserialize: %w" , err )
1142
1141
}
1143
1142
0 commit comments