mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #63522 from atlassian/remove-json-int
Automatic merge from submit-queue (batch tested with PRs 65094, 65533, 63522, 65694, 65702). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove int support from json patches **What this PR does / why we need it**: JSON only contains `int64` and `float64` types for numbers so `int` is not needed. **Special notes for your reviewer**: This is a follow up for https://github.com/kubernetes/kubernetes/pull/62981. **Release note**: ```release-note NONE ``` /sig api-machinery /kind cleanup /cc liggitt sttts
This commit is contained in:
commit
74b764224a
@ -136,7 +136,7 @@ func keepOrDeleteNullInObj(m map[string]interface{}, keepNull bool) (map[string]
|
||||
filteredMap[key] = filteredSubMap
|
||||
}
|
||||
|
||||
case []interface{}, string, float64, bool, int, int64, nil:
|
||||
case []interface{}, string, float64, bool, int64, nil:
|
||||
// Lists are always replaced in Json, no need to check each entry in the list.
|
||||
if !keepNull {
|
||||
filteredMap[key] = val
|
||||
|
@ -125,7 +125,7 @@ func HasConflicts(left, right interface{}) (bool, error) {
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
case string, float64, bool, int, int64, nil:
|
||||
case string, float64, bool, int64, nil:
|
||||
return !reflect.DeepEqual(left, right), nil
|
||||
default:
|
||||
return true, fmt.Errorf("unknown type: %v", reflect.TypeOf(left))
|
||||
|
@ -30,82 +30,80 @@ func TestHasConflicts(t *testing.T) {
|
||||
{A: "hello", B: "hello", Ret: false},
|
||||
{A: "hello", B: "hell", Ret: true},
|
||||
{A: "hello", B: nil, Ret: true},
|
||||
{A: "hello", B: 1, Ret: true},
|
||||
{A: "hello", B: int64(1), Ret: true},
|
||||
{A: "hello", B: float64(1.0), Ret: true},
|
||||
{A: "hello", B: false, Ret: true},
|
||||
{A: 1, B: 1, Ret: false},
|
||||
{A: int64(1), B: int64(1), Ret: false},
|
||||
{A: nil, B: nil, Ret: false},
|
||||
{A: false, B: false, Ret: false},
|
||||
{A: float64(3), B: float64(3), Ret: false},
|
||||
|
||||
{A: "hello", B: []interface{}{}, Ret: true},
|
||||
{A: []interface{}{1}, B: []interface{}{}, Ret: true},
|
||||
{A: []interface{}{int64(1)}, B: []interface{}{}, Ret: true},
|
||||
{A: []interface{}{}, B: []interface{}{}, Ret: false},
|
||||
{A: []interface{}{1}, B: []interface{}{1}, Ret: false},
|
||||
{A: map[string]interface{}{}, B: []interface{}{1}, Ret: true},
|
||||
{A: []interface{}{int64(1)}, B: []interface{}{int64(1)}, Ret: false},
|
||||
{A: map[string]interface{}{}, B: []interface{}{int64(1)}, Ret: true},
|
||||
|
||||
{A: map[string]interface{}{}, B: map[string]interface{}{"a": 1}, Ret: false},
|
||||
{A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"a": 1}, Ret: false},
|
||||
{A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"a": 2}, Ret: true},
|
||||
{A: map[string]interface{}{"a": 1}, B: map[string]interface{}{"b": 2}, Ret: false},
|
||||
{A: map[string]interface{}{}, B: map[string]interface{}{"a": int64(1)}, Ret: false},
|
||||
{A: map[string]interface{}{"a": int64(1)}, B: map[string]interface{}{"a": int64(1)}, Ret: false},
|
||||
{A: map[string]interface{}{"a": int64(1)}, B: map[string]interface{}{"a": int64(2)}, Ret: true},
|
||||
{A: map[string]interface{}{"a": int64(1)}, B: map[string]interface{}{"b": int64(2)}, Ret: false},
|
||||
|
||||
{
|
||||
A: map[string]interface{}{"a": []interface{}{1}},
|
||||
B: map[string]interface{}{"a": []interface{}{1}},
|
||||
A: map[string]interface{}{"a": []interface{}{int64(1)}},
|
||||
B: map[string]interface{}{"a": []interface{}{int64(1)}},
|
||||
Ret: false,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": []interface{}{1}},
|
||||
A: map[string]interface{}{"a": []interface{}{int64(1)}},
|
||||
B: map[string]interface{}{"a": []interface{}{}},
|
||||
Ret: true,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": []interface{}{1}},
|
||||
B: map[string]interface{}{"a": 1},
|
||||
A: map[string]interface{}{"a": []interface{}{int64(1)}},
|
||||
B: map[string]interface{}{"a": int64(1)},
|
||||
Ret: true,
|
||||
},
|
||||
|
||||
// Maps and lists with multiple entries.
|
||||
{
|
||||
A: map[string]interface{}{"a": 1, "b": 2},
|
||||
B: map[string]interface{}{"a": 1, "b": 0},
|
||||
A: map[string]interface{}{"a": int64(1), "b": int64(2)},
|
||||
B: map[string]interface{}{"a": int64(1), "b": int64(0)},
|
||||
Ret: true,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": 1, "b": 2},
|
||||
B: map[string]interface{}{"a": 1, "b": 2},
|
||||
A: map[string]interface{}{"a": int64(1), "b": int64(2)},
|
||||
B: map[string]interface{}{"a": int64(1), "b": int64(2)},
|
||||
Ret: false,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": 1, "b": 2},
|
||||
B: map[string]interface{}{"a": 1, "b": 0, "c": 3},
|
||||
A: map[string]interface{}{"a": int64(1), "b": int64(2)},
|
||||
B: map[string]interface{}{"a": int64(1), "b": int64(0), "c": int64(3)},
|
||||
Ret: true,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": 1, "b": 2},
|
||||
B: map[string]interface{}{"a": 1, "b": 2, "c": 3},
|
||||
A: map[string]interface{}{"a": int64(1), "b": int64(2)},
|
||||
B: map[string]interface{}{"a": int64(1), "b": int64(2), "c": int64(3)},
|
||||
Ret: false,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": []interface{}{1, 2}},
|
||||
B: map[string]interface{}{"a": []interface{}{1, 0}},
|
||||
A: map[string]interface{}{"a": []interface{}{int64(1), int64(2)}},
|
||||
B: map[string]interface{}{"a": []interface{}{int64(1), int64(0)}},
|
||||
Ret: true,
|
||||
},
|
||||
{
|
||||
A: map[string]interface{}{"a": []interface{}{1, 2}},
|
||||
B: map[string]interface{}{"a": []interface{}{1, 2}},
|
||||
A: map[string]interface{}{"a": []interface{}{int64(1), int64(2)}},
|
||||
B: map[string]interface{}{"a": []interface{}{int64(1), int64(2)}},
|
||||
Ret: false,
|
||||
},
|
||||
|
||||
// Numeric types are not interchangeable.
|
||||
// Callers are expected to ensure numeric types are consistent in 'left' and 'right'.
|
||||
{A: int(0), B: int64(0), Ret: true},
|
||||
{A: int(0), B: float64(0), Ret: true},
|
||||
{A: int64(0), B: float64(0), Ret: true},
|
||||
// Other types are not interchangeable.
|
||||
{A: int(0), B: "0", Ret: true},
|
||||
{A: int(0), B: nil, Ret: true},
|
||||
{A: int(0), B: false, Ret: true},
|
||||
{A: int64(0), B: "0", Ret: true},
|
||||
{A: int64(0), B: nil, Ret: true},
|
||||
{A: int64(0), B: false, Ret: true},
|
||||
{A: "true", B: true, Ret: true},
|
||||
{A: "null", B: nil, Ret: true},
|
||||
}
|
||||
|
@ -1876,7 +1876,7 @@ func mergingMapFieldsHaveConflicts(
|
||||
return true, nil
|
||||
}
|
||||
return slicesHaveConflicts(leftType, rightType, schema, fieldPatchStrategy, fieldPatchMergeKey)
|
||||
case string, float64, bool, int, int64, nil:
|
||||
case string, float64, bool, int64, nil:
|
||||
return !reflect.DeepEqual(left, right), nil
|
||||
default:
|
||||
return true, fmt.Errorf("unknown type: %v", reflect.TypeOf(left))
|
||||
|
Loading…
Reference in New Issue
Block a user