mirror of https://github.com/k3s-io/k3s
fix todo: add validate method for &schedulerapi.Policy
parent
f3942e7ded
commit
ba3339a1fb
|
@ -41,6 +41,7 @@ go_test(
|
|||
"//pkg/registry/batch/job:go_default_library",
|
||||
"//pkg/scheduler/api: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/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
|
|
@ -44,6 +44,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/registry/batch/job"
|
||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||
schedulerapilatest "k8s.io/kubernetes/pkg/scheduler/api/latest"
|
||||
schedulerapivalidation "k8s.io/kubernetes/pkg/scheduler/api/validation"
|
||||
)
|
||||
|
||||
func validateObject(obj runtime.Object) (errors field.ErrorList) {
|
||||
|
@ -144,6 +145,15 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
|
|||
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 {
|
||||
return filepath.Walk(inDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
|
@ -357,7 +367,10 @@ func TestExampleObjectSchemas(t *testing.T) {
|
|||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
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 {
|
||||
codec, err := testapi.GetCodecForObject(expectedType)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue