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
ba3339a1
Commit
ba3339a1
authored
Feb 22, 2018
by
hangaoshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix todo: add validate method for &schedulerapi.Policy
parent
f3942e7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
BUILD
examples/BUILD
+1
-0
examples_test.go
examples/examples_test.go
+14
-1
No files found.
examples/BUILD
View file @
ba3339a1
...
@@ -41,6 +41,7 @@ go_test(
...
@@ -41,6 +41,7 @@ go_test(
"//pkg/registry/batch/job:go_default_library",
"//pkg/registry/batch/job:go_default_library",
"//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/api:go_default_library",
"//pkg/scheduler/api/latest:go_default_library",
"//pkg/scheduler/api/latest:go_default_library",
"//pkg/scheduler/api/validation:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
...
...
examples/examples_test.go
View file @
ba3339a1
...
@@ -44,6 +44,7 @@ import (
...
@@ -44,6 +44,7 @@ import (
"k8s.io/kubernetes/pkg/registry/batch/job"
"k8s.io/kubernetes/pkg/registry/batch/job"
schedulerapi
"k8s.io/kubernetes/pkg/scheduler/api"
schedulerapi
"k8s.io/kubernetes/pkg/scheduler/api"
schedulerapilatest
"k8s.io/kubernetes/pkg/scheduler/api/latest"
schedulerapilatest
"k8s.io/kubernetes/pkg/scheduler/api/latest"
schedulerapivalidation
"k8s.io/kubernetes/pkg/scheduler/api/validation"
)
)
func
validateObject
(
obj
runtime
.
Object
)
(
errors
field
.
ErrorList
)
{
func
validateObject
(
obj
runtime
.
Object
)
(
errors
field
.
ErrorList
)
{
...
@@ -144,6 +145,15 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
...
@@ -144,6 +145,15 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
return
errors
return
errors
}
}
func
validateschedulerpolicy
(
obj
runtime
.
Object
)
error
{
switch
t
:=
obj
.
(
type
)
{
case
*
schedulerapi
.
Policy
:
return
schedulerapivalidation
.
ValidatePolicy
(
*
t
)
default
:
return
fmt
.
Errorf
(
"obj type is not schedulerapi.Policy"
)
}
}
func
walkJSONFiles
(
inDir
string
,
fn
func
(
name
,
path
string
,
data
[]
byte
))
error
{
func
walkJSONFiles
(
inDir
string
,
fn
func
(
name
,
path
string
,
data
[]
byte
))
error
{
return
filepath
.
Walk
(
inDir
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
return
filepath
.
Walk
(
inDir
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -357,7 +367,10 @@ func TestExampleObjectSchemas(t *testing.T) {
...
@@ -357,7 +367,10 @@ func TestExampleObjectSchemas(t *testing.T) {
t
.
Errorf
(
"%s did not decode correctly: %v
\n
%s"
,
path
,
err
,
string
(
data
))
t
.
Errorf
(
"%s did not decode correctly: %v
\n
%s"
,
path
,
err
,
string
(
data
))
return
return
}
}
//TODO: Add validate method for &schedulerapi.Policy
if
err
:=
validateschedulerpolicy
(
expectedType
);
err
!=
nil
{
t
.
Errorf
(
"%s did not validate correctly: %v
\n
%s"
,
path
,
err
,
string
(
data
))
return
}
}
else
{
}
else
{
codec
,
err
:=
testapi
.
GetCodecForObject
(
expectedType
)
codec
,
err
:=
testapi
.
GetCodecForObject
(
expectedType
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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