mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-31 16:46:54 +00:00
Merge pull request #59256 from hanxiaoshuai/fixtodo02021
Automatic merge from submit-queue (batch tested with PRs 60011, 59256, 59293, 60328, 60367). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix todo: add validate method for &schedulerapi.Policy in examples_test.go **What this PR does / why we need it**: fix todo: add validate method for &schedulerapi.Policy in examples_test.go **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
@@ -40,6 +40,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 {
|
||||
@@ -351,7 +361,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 {
|
||||
|
Reference in New Issue
Block a user