aboutsummaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/json/json.go25
-rw-r--r--vendor/modules.txt4
2 files changed, 27 insertions, 2 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/util/json/json.go b/vendor/k8s.io/apimachinery/pkg/util/json/json.go
index 0e2e30175..204834883 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/json/json.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/json/json.go
@@ -66,11 +66,36 @@ func Unmarshal(data []byte, v interface{}) error {
// If the decode succeeds, post-process the map to convert json.Number objects to int64 or float64
return convertSliceNumbers(*v, 0)
+ case *interface{}:
+ // Build a decoder from the given data
+ decoder := json.NewDecoder(bytes.NewBuffer(data))
+ // Preserve numbers, rather than casting to float64 automatically
+ decoder.UseNumber()
+ // Run the decode
+ if err := decoder.Decode(v); err != nil {
+ return err
+ }
+ // If the decode succeeds, post-process the map to convert json.Number objects to int64 or float64
+ return convertInterfaceNumbers(v, 0)
+
default:
return json.Unmarshal(data, v)
}
}
+func convertInterfaceNumbers(v *interface{}, depth int) error {
+ var err error
+ switch v2 := (*v).(type) {
+ case json.Number:
+ *v, err = convertNumber(v2)
+ case map[string]interface{}:
+ err = convertMapNumbers(v2, depth+1)
+ case []interface{}:
+ err = convertSliceNumbers(v2, depth+1)
+ }
+ return err
+}
+
// convertMapNumbers traverses the map, converting any json.Number values to int64 or float64.
// values which are map[string]interface{} or []interface{} are recursively visited
func convertMapNumbers(m map[string]interface{}, depth int) error {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 2e8976d47..d82137dac 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -681,9 +681,9 @@ gopkg.in/square/go-jose.v2/json
gopkg.in/tomb.v1
# gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v2
-# k8s.io/api v0.18.2
+# k8s.io/api v0.18.3
k8s.io/api/core/v1
-# k8s.io/apimachinery v0.18.2
+# k8s.io/apimachinery v0.18.3
k8s.io/apimachinery/pkg/api/errors
k8s.io/apimachinery/pkg/api/resource
k8s.io/apimachinery/pkg/apis/meta/v1