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
d9cc8119
Commit
d9cc8119
authored
Oct 12, 2016
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow apigroups to opt out of proto round trip testing
parent
04437f64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
serialization_proto_test.go
pkg/api/serialization_proto_test.go
+8
-2
serialization_test.go
pkg/api/serialization_test.go
+8
-4
No files found.
pkg/api/serialization_proto_test.go
View file @
d9cc8119
...
...
@@ -33,12 +33,18 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime/serializer/protobuf"
"k8s.io/kubernetes/pkg/util/diff"
"k8s.io/kubernetes/pkg/util/sets"
)
var
nonProtobaleAPIGroups
=
sets
.
NewString
()
func
init
()
{
codecsToTest
=
append
(
codecsToTest
,
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
error
)
{
codecsToTest
=
append
(
codecsToTest
,
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
bool
,
error
)
{
if
nonProtobaleAPIGroups
.
Has
(
version
.
Group
)
{
return
nil
,
false
,
nil
}
s
:=
protobuf
.
NewSerializer
(
api
.
Scheme
,
api
.
Scheme
,
"application/arbitrary.content.type"
)
return
api
.
Codecs
.
CodecForVersions
(
s
,
s
,
testapi
.
ExternalGroupVersions
(),
nil
),
nil
return
api
.
Codecs
.
CodecForVersions
(
s
,
s
,
testapi
.
ExternalGroupVersions
(),
nil
),
true
,
nil
})
}
...
...
pkg/api/serialization_test.go
View file @
d9cc8119
...
...
@@ -51,9 +51,10 @@ import (
var
fuzzIters
=
flag
.
Int
(
"fuzz-iters"
,
20
,
"How many fuzzing iterations to do."
)
var
codecsToTest
=
[]
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
error
){
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
error
)
{
return
testapi
.
GetCodecForObject
(
item
)
var
codecsToTest
=
[]
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
bool
,
error
){
func
(
version
unversioned
.
GroupVersion
,
item
runtime
.
Object
)
(
runtime
.
Codec
,
bool
,
error
)
{
c
,
err
:=
testapi
.
GetCodecForObject
(
item
)
return
c
,
true
,
err
},
}
...
...
@@ -135,11 +136,14 @@ func roundTripSame(t *testing.T, group testapi.TestGroup, item runtime.Object, e
version
:=
*
group
.
GroupVersion
()
codecs
:=
[]
runtime
.
Codec
{}
for
_
,
fn
:=
range
codecsToTest
{
codec
,
err
:=
fn
(
version
,
item
)
codec
,
ok
,
err
:=
fn
(
version
,
item
)
if
err
!=
nil
{
t
.
Errorf
(
"unable to get codec: %v"
,
err
)
return
}
if
!
ok
{
continue
}
codecs
=
append
(
codecs
,
codec
)
}
...
...
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