• k8s-merge-robot's avatar
    Merge pull request #16964 from liggitt/json_precision · fcddb9cb
    k8s-merge-robot authored
    Automatic merge from submit-queue
    
    Preserve int data when unmarshaling
    
    There are several places we use `json.Unmarshal` into an unstructured map (StrategicMergePatch, UnstructuredJSONScheme, many others).
    
    In this scenario, the json package converts all numbers to float64. This exposes many of the int64 fields in our API types to corruption when the unstructured map is marshalled back to json.
    
    A simple example is a pod with an `"activeDeadlineSeconds": 1000000`. Trying to use `kubectl label`, `annotate`, `patch`, etc results in that int64 being converted to a float64, submitted to the server, and the server rejecting it with an error about "cannot unmarshal number 1e+6 into Go value of type int64"
    
    The json package provides a way to defer conversion of numbers (`json.Decoder#UseNumber`), but does not actually do conversions to int or float. This PR makes use of that feature, and post-processes the unmarshalled map to convert json.Number objects to either int64 or float64 values
    fcddb9cb
Name
Last commit
Last update
..
atomic Loading commit data...
bandwidth Loading commit data...
cache Loading commit data...
chmod Loading commit data...
chown Loading commit data...
codeinspector Loading commit data...
config Loading commit data...
configz Loading commit data...
crlf Loading commit data...
crypto Loading commit data...
dbus Loading commit data...
deployment Loading commit data...
diff Loading commit data...
env Loading commit data...
errors Loading commit data...
exec Loading commit data...
flag Loading commit data...
flock Loading commit data...
flowcontrol Loading commit data...
flushwriter Loading commit data...
hash Loading commit data...
homedir Loading commit data...
httpstream Loading commit data...
integer Loading commit data...
interrupt Loading commit data...
intstr Loading commit data...
io Loading commit data...
iptables Loading commit data...
json Loading commit data...
jsonpath Loading commit data...
keymutex Loading commit data...
labels Loading commit data...
limitwriter Loading commit data...
mount Loading commit data...
net Loading commit data...
node Loading commit data...
oom Loading commit data...
parsers Loading commit data...
pod Loading commit data...
procfs Loading commit data...
proxy Loading commit data...
rand Loading commit data...
replicaset Loading commit data...
runtime Loading commit data...
selinux Loading commit data...
sets Loading commit data...
slice Loading commit data...
strategicpatch Loading commit data...
strings Loading commit data...
sysctl Loading commit data...
system Loading commit data...
term Loading commit data...
testing Loading commit data...
threading Loading commit data...
validation Loading commit data...
wait Loading commit data...
workqueue Loading commit data...
wsstream Loading commit data...
yaml Loading commit data...
clock.go Loading commit data...
clock_test.go Loading commit data...
doc.go Loading commit data...
line_delimiter.go Loading commit data...
line_delimiter_test.go Loading commit data...
logs.go Loading commit data...
resource_container_linux.go Loading commit data...
resource_container_unsupported.go Loading commit data...
runner.go Loading commit data...
runner_test.go Loading commit data...
string_flag.go Loading commit data...
template.go Loading commit data...
template_test.go Loading commit data...
trace.go Loading commit data...
umask.go Loading commit data...
umask_windows.go Loading commit data...
util.go Loading commit data...
util_test.go Loading commit data...
uuid.go Loading commit data...