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
59dfbe44
Commit
59dfbe44
authored
Jan 10, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Selfer codec impl from Verbs and add regression tests
parent
90458924
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
27 deletions
+26
-27
types.go
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
+0
-23
types_test.go
...ng/src/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
+26
-4
No files found.
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
View file @
59dfbe44
...
...
@@ -29,8 +29,6 @@ import (
"fmt"
"strings"
"github.com/ugorji/go/codec"
"k8s.io/apimachinery/pkg/types"
)
...
...
@@ -445,27 +443,6 @@ func (vs Verbs) String() string {
return
fmt
.
Sprintf
(
"%v"
,
[]
string
(
vs
))
}
// CodecEncodeSelf is part of the codec.Selfer interface.
func
(
vs
*
Verbs
)
CodecEncodeSelf
(
encoder
*
codec
.
Encoder
)
{
encoder
.
Encode
(
vs
)
}
// CodecDecodeSelf is part of the codec.Selfer interface. It is overwritten here to make sure
// that an empty verbs list is not decoded as nil. On the other hand, an undefined verbs list
// will lead to nil because this decoding for Verbs is not invoked.
//
// TODO(sttts): this is due to a ugorji regression: https://github.com/ugorji/go/issues/119. Remove the
// workaround when the regression is fixed.
func
(
vs
*
Verbs
)
CodecDecodeSelf
(
decoder
*
codec
.
Decoder
)
{
m
:=
[]
string
{}
decoder
.
Decode
(
&
m
)
if
len
(
m
)
==
0
{
*
vs
=
[]
string
{}
}
else
{
*
vs
=
m
}
}
// APIResourceList is a list of APIResource, it is used to expose the name of the
// resources supported in a specific group and version, and if the resource
// is namespaced.
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types_test.go
View file @
59dfbe44
...
...
@@ -24,7 +24,7 @@ import (
"github.com/ugorji/go/codec"
)
func
TestVerbsMarshalJSON
(
t
*
testing
.
T
)
{
func
TestVerbs
Ugorji
MarshalJSON
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
input
APIResource
result
string
...
...
@@ -40,12 +40,12 @@ func TestVerbsMarshalJSON(t *testing.T) {
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
}
if
string
(
result
)
!=
c
.
result
{
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': expected
%+v, got %q
"
,
i
,
c
.
input
,
c
.
result
,
string
(
result
))
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': expected
'%v', got '%v'
"
,
i
,
c
.
input
,
c
.
result
,
string
(
result
))
}
}
}
func
TestVerbsUnmarshalJSON
(
t
*
testing
.
T
)
{
func
TestVerbsU
gorjiU
nmarshalJSON
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
input
string
result
APIResource
...
...
@@ -67,7 +67,29 @@ func TestVerbsUnmarshalJSON(t *testing.T) {
}
}
func
TestVerbsUgorjiUnmarshalJSON
(
t
*
testing
.
T
)
{
// TestUgorjiMarshalJSONWithOmit tests that we don't have regressions regarding nil and empty slices with "omit"
func
TestUgorjiMarshalJSONWithOmit
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
input
LabelSelector
result
string
}{
{
LabelSelector
{},
`{}`
},
{
LabelSelector
{
MatchExpressions
:
[]
LabelSelectorRequirement
{}},
`{}`
},
{
LabelSelector
{
MatchExpressions
:
[]
LabelSelectorRequirement
{{}}},
`{"matchExpressions":[{"key":"","operator":""}]}`
},
}
for
i
,
c
:=
range
cases
{
result
,
err
:=
json
.
Marshal
(
&
c
.
input
)
if
err
!=
nil
{
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': %v"
,
i
,
c
.
input
,
err
)
}
if
string
(
result
)
!=
c
.
result
{
t
.
Errorf
(
"[%d] Failed to marshal input: '%v': expected '%v', got '%v'"
,
i
,
c
.
input
,
c
.
result
,
string
(
result
))
}
}
}
func
TestVerbsUnmarshalJSON
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
input
string
result
APIResource
...
...
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