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
7b0e45a5
Commit
7b0e45a5
authored
Mar 31, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defaults_tests: verify defaults when converting to an API object
This change verifies that defaults are applied after decoding an versioned object into an API object.
parent
e2dcf298
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
+29
-10
types.go
pkg/api/types.go
+2
-1
defaults_test.go
pkg/api/v1beta1/defaults_test.go
+9
-3
defaults_test.go
pkg/api/v1beta2/defaults_test.go
+9
-3
defaults_test.go
pkg/api/v1beta3/defaults_test.go
+9
-3
No files found.
pkg/api/types.go
View file @
7b0e45a5
...
...
@@ -1507,7 +1507,8 @@ type ContainerManifest struct {
Containers
[]
Container
`json:"containers"`
RestartPolicy
RestartPolicy
`json:"restartPolicy,omitempty"`
// Required: Set DNS policy.
DNSPolicy
DNSPolicy
`json:"dnsPolicy"`
DNSPolicy
DNSPolicy
`json:"dnsPolicy"`
HostNetwork
bool
`json:"hostNetwork,omitempty"`
}
// ContainerManifestList is used to communicate container manifests to kubelet.
...
...
pkg/api/v1beta1/defaults_test.go
View file @
7b0e45a5
...
...
@@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
...
...
@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t
.
Errorf
(
"%v
\n
%#v"
,
err
,
obj
)
return
nil
}
obj2
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
current
.
Codec
.
DecodeInto
(
data
,
obj2
)
obj2
,
err
:=
newer
.
Codec
.
Decode
(
data
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Data: %s
\n
Source: %#v"
,
err
,
string
(
data
),
obj
)
return
nil
}
return
obj2
obj3
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
newer
.
Scheme
.
Convert
(
obj2
,
obj3
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Source: %#v"
,
err
,
obj2
)
return
nil
}
return
obj3
}
func
TestSetDefaultService
(
t
*
testing
.
T
)
{
...
...
pkg/api/v1beta2/defaults_test.go
View file @
7b0e45a5
...
...
@@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
...
...
@@ -30,13 +31,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t
.
Errorf
(
"%v
\n
%#v"
,
err
,
obj
)
return
nil
}
obj2
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
current
.
Codec
.
DecodeInto
(
data
,
obj2
)
obj2
,
err
:=
newer
.
Codec
.
Decode
(
data
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Data: %s
\n
Source: %#v"
,
err
,
string
(
data
),
obj
)
return
nil
}
return
obj2
obj3
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
newer
.
Scheme
.
Convert
(
obj2
,
obj3
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Source: %#v"
,
err
,
obj2
)
return
nil
}
return
obj3
}
func
TestSetDefaultService
(
t
*
testing
.
T
)
{
...
...
pkg/api/v1beta3/defaults_test.go
View file @
7b0e45a5
...
...
@@ -20,6 +20,7 @@ import (
"reflect"
"testing"
newer
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
current
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
...
@@ -31,13 +32,18 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
t
.
Errorf
(
"%v
\n
%#v"
,
err
,
obj
)
return
nil
}
obj2
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
current
.
Codec
.
DecodeInto
(
data
,
obj2
)
obj2
,
err
:=
newer
.
Codec
.
Decode
(
data
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Data: %s
\n
Source: %#v"
,
err
,
string
(
data
),
obj
)
return
nil
}
return
obj2
obj3
:=
reflect
.
New
(
reflect
.
TypeOf
(
obj
)
.
Elem
())
.
Interface
()
.
(
runtime
.
Object
)
err
=
newer
.
Scheme
.
Convert
(
obj2
,
obj3
)
if
err
!=
nil
{
t
.
Errorf
(
"%v
\n
Source: %#v"
,
err
,
obj2
)
return
nil
}
return
obj3
}
func
TestSetDefaultService
(
t
*
testing
.
T
)
{
...
...
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