Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0623068f
Commit
0623068f
authored
Jun 21, 2018
by
Nikhita Raghunath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix k8s json package import name
parent
23b4690d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
serialization_test.go
pkg/api/testing/serialization_test.go
+5
-5
group_version_test.go
...8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go
+5
-5
types_test.go
...ng/src/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
+10
-10
No files found.
pkg/api/testing/serialization_test.go
View file @
0623068f
...
@@ -19,7 +19,7 @@ package testing
...
@@ -19,7 +19,7 @@ package testing
import
(
import
(
"bytes"
"bytes"
"encoding/hex"
"encoding/hex"
"encoding/json"
gojson
"encoding/json"
"io/ioutil"
"io/ioutil"
"math/rand"
"math/rand"
"reflect"
"reflect"
...
@@ -37,7 +37,7 @@ import (
...
@@ -37,7 +37,7 @@ import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
k8s_json
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -437,7 +437,7 @@ func BenchmarkEncodeJSONMarshal(b *testing.B) {
...
@@ -437,7 +437,7 @@ func BenchmarkEncodeJSONMarshal(b *testing.B) {
width
:=
len
(
items
)
width
:=
len
(
items
)
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
if
_
,
err
:=
json
.
Marshal
(
&
items
[
i
%
width
]);
err
!=
nil
{
if
_
,
err
:=
go
json
.
Marshal
(
&
items
[
i
%
width
]);
err
!=
nil
{
b
.
Fatal
(
err
)
b
.
Fatal
(
err
)
}
}
}
}
...
@@ -529,7 +529,7 @@ func BenchmarkDecodeIntoJSON(b *testing.B) {
...
@@ -529,7 +529,7 @@ func BenchmarkDecodeIntoJSON(b *testing.B) {
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
obj
:=
v1
.
Pod
{}
obj
:=
v1
.
Pod
{}
if
err
:=
json
.
Unmarshal
(
encoded
[
i
%
width
],
&
obj
);
err
!=
nil
{
if
err
:=
go
json
.
Unmarshal
(
encoded
[
i
%
width
],
&
obj
);
err
!=
nil
{
b
.
Fatal
(
err
)
b
.
Fatal
(
err
)
}
}
}
}
...
@@ -579,7 +579,7 @@ func BenchmarkDecodeIntoJSONCodecGenConfigCompatibleWithStandardLibrary(b *testi
...
@@ -579,7 +579,7 @@ func BenchmarkDecodeIntoJSONCodecGenConfigCompatibleWithStandardLibrary(b *testi
}
}
b
.
ResetTimer
()
b
.
ResetTimer
()
iter
:=
k8s_
json
.
CaseSensitiveJsonIterator
()
iter
:=
json
.
CaseSensitiveJsonIterator
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
obj
:=
v1
.
Pod
{}
obj
:=
v1
.
Pod
{}
if
err
:=
iter
.
Unmarshal
(
encoded
[
i
%
width
],
&
obj
);
err
!=
nil
{
if
err
:=
iter
.
Unmarshal
(
encoded
[
i
%
width
],
&
obj
);
err
!=
nil
{
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go
View file @
0623068f
...
@@ -17,11 +17,11 @@ limitations under the License.
...
@@ -17,11 +17,11 @@ limitations under the License.
package
v1
package
v1
import
(
import
(
"encoding/json"
gojson
"encoding/json"
"reflect"
"reflect"
"testing"
"testing"
k8s_json
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
)
)
type
GroupVersionHolder
struct
{
type
GroupVersionHolder
struct
{
...
@@ -40,14 +40,14 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
...
@@ -40,14 +40,14 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
for
_
,
c
:=
range
cases
{
for
_
,
c
:=
range
cases
{
var
result
GroupVersionHolder
var
result
GroupVersionHolder
// test golang lib's JSON codec
// test golang lib's JSON codec
if
err
:=
json
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
if
err
:=
go
json
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
t
.
Errorf
(
"JSON codec failed to unmarshal input '%v': %v"
,
c
.
input
,
err
)
t
.
Errorf
(
"JSON codec failed to unmarshal input '%v': %v"
,
c
.
input
,
err
)
}
}
if
!
reflect
.
DeepEqual
(
result
.
GV
,
c
.
expect
)
{
if
!
reflect
.
DeepEqual
(
result
.
GV
,
c
.
expect
)
{
t
.
Errorf
(
"JSON codec failed to unmarshal input '%s': expected %+v, got %+v"
,
c
.
input
,
c
.
expect
,
result
.
GV
)
t
.
Errorf
(
"JSON codec failed to unmarshal input '%s': expected %+v, got %+v"
,
c
.
input
,
c
.
expect
,
result
.
GV
)
}
}
// test the json-iterator codec
// test the json-iterator codec
iter
:=
k8s_
json
.
CaseSensitiveJsonIterator
()
iter
:=
json
.
CaseSensitiveJsonIterator
()
if
err
:=
iter
.
Unmarshal
(
c
.
input
,
&
result
);
err
!=
nil
{
if
err
:=
iter
.
Unmarshal
(
c
.
input
,
&
result
);
err
!=
nil
{
t
.
Errorf
(
"json-iterator codec failed to unmarshal input '%v': %v"
,
c
.
input
,
err
)
t
.
Errorf
(
"json-iterator codec failed to unmarshal input '%v': %v"
,
c
.
input
,
err
)
}
}
...
@@ -68,7 +68,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) {
for
_
,
c
:=
range
cases
{
for
_
,
c
:=
range
cases
{
input
:=
GroupVersionHolder
{
c
.
input
}
input
:=
GroupVersionHolder
{
c
.
input
}
result
,
err
:=
json
.
Marshal
(
&
input
)
result
,
err
:=
go
json
.
Marshal
(
&
input
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to marshal input '%v': %v"
,
input
,
err
)
t
.
Errorf
(
"Failed to marshal input '%v': %v"
,
input
,
err
)
}
}
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
View file @
0623068f
...
@@ -17,14 +17,14 @@ limitations under the License.
...
@@ -17,14 +17,14 @@ limitations under the License.
package
v1
package
v1
import
(
import
(
"encoding/json"
gojson
"encoding/json"
"reflect"
"reflect"
"testing"
"testing"
k8s_json
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
)
)
func
TestVerbs
Ugorji
MarshalJSON
(
t
*
testing
.
T
)
{
func
TestVerbsMarshalJSON
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
cases
:=
[]
struct
{
input
APIResource
input
APIResource
result
string
result
string
...
@@ -35,7 +35,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
}
}
for
i
,
c
:=
range
cases
{
for
i
,
c
:=
range
cases
{
result
,
err
:=
json
.
Marshal
(
&
c
.
input
)
result
,
err
:=
go
json
.
Marshal
(
&
c
.
input
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
}
}
...
@@ -45,7 +45,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
...
@@ -45,7 +45,7 @@ func TestVerbsUgorjiMarshalJSON(t *testing.T) {
}
}
}
}
func
TestVerbs
U
JsonIterUnmarshalJSON
(
t
*
testing
.
T
)
{
func
TestVerbsJsonIterUnmarshalJSON
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
cases
:=
[]
struct
{
input
string
input
string
result
APIResource
result
APIResource
...
@@ -56,7 +56,7 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
...
@@ -56,7 +56,7 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
{
`{"verbs":["delete"]}`
,
APIResource
{
Verbs
:
Verbs
([]
string
{
"delete"
})}},
{
`{"verbs":["delete"]}`
,
APIResource
{
Verbs
:
Verbs
([]
string
{
"delete"
})}},
}
}
iter
:=
k8s_
json
.
CaseSensitiveJsonIterator
()
iter
:=
json
.
CaseSensitiveJsonIterator
()
for
i
,
c
:=
range
cases
{
for
i
,
c
:=
range
cases
{
var
result
APIResource
var
result
APIResource
if
err
:=
iter
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
if
err
:=
iter
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
...
@@ -68,8 +68,8 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
...
@@ -68,8 +68,8 @@ func TestVerbsUJsonIterUnmarshalJSON(t *testing.T) {
}
}
}
}
// Test
Ugorji
MarshalJSONWithOmit tests that we don't have regressions regarding nil and empty slices with "omit"
// TestMarshalJSONWithOmit tests that we don't have regressions regarding nil and empty slices with "omit"
func
Test
Ugorji
MarshalJSONWithOmit
(
t
*
testing
.
T
)
{
func
TestMarshalJSONWithOmit
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
cases
:=
[]
struct
{
input
LabelSelector
input
LabelSelector
result
string
result
string
...
@@ -80,7 +80,7 @@ func TestUgorjiMarshalJSONWithOmit(t *testing.T) {
...
@@ -80,7 +80,7 @@ func TestUgorjiMarshalJSONWithOmit(t *testing.T) {
}
}
for
i
,
c
:=
range
cases
{
for
i
,
c
:=
range
cases
{
result
,
err
:=
json
.
Marshal
(
&
c
.
input
)
result
,
err
:=
go
json
.
Marshal
(
&
c
.
input
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
}
}
...
@@ -103,7 +103,7 @@ func TestVerbsUnmarshalJSON(t *testing.T) {
...
@@ -103,7 +103,7 @@ func TestVerbsUnmarshalJSON(t *testing.T) {
for
i
,
c
:=
range
cases
{
for
i
,
c
:=
range
cases
{
var
result
APIResource
var
result
APIResource
if
err
:=
json
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
if
err
:=
go
json
.
Unmarshal
([]
byte
(
c
.
input
),
&
result
);
err
!=
nil
{
t
.
Errorf
(
"[%d] Failed to unmarshal input '%v': %v"
,
i
,
c
.
input
,
err
)
t
.
Errorf
(
"[%d] Failed to unmarshal input '%v': %v"
,
i
,
c
.
input
,
err
)
}
}
if
!
reflect
.
DeepEqual
(
result
,
c
.
result
)
{
if
!
reflect
.
DeepEqual
(
result
,
c
.
result
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment