Replace godep with dep
This commit is contained in:
parent
1e7489927c
commit
bf5616c65b
14883 changed files with 3937406 additions and 361781 deletions
36
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/BUILD
generated
vendored
Normal file
36
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["validation.go"],
|
||||
deps = [
|
||||
"//plugin/pkg/scheduler/api:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["validation_test.go"],
|
||||
library = ":go_default_library",
|
||||
deps = ["//plugin/pkg/scheduler/api:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
50
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation.go
generated
vendored
Normal file
50
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation.go
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
schedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
// ValidatePolicy checks for errors in the Config
|
||||
// It does not return early so that it can find as many errors as possible
|
||||
func ValidatePolicy(policy schedulerapi.Policy) error {
|
||||
var validationErrors []error
|
||||
|
||||
for _, priority := range policy.Priorities {
|
||||
if priority.Weight <= 0 || priority.Weight >= schedulerapi.MaxWeight {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Priority %s should have a positive weight applied to it or it has overflown", priority.Name))
|
||||
}
|
||||
}
|
||||
|
||||
binders := 0
|
||||
for _, extender := range policy.ExtenderConfigs {
|
||||
if extender.Weight <= 0 {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Priority for extender %s should have a positive weight applied to it", extender.URLPrefix))
|
||||
}
|
||||
if extender.BindVerb != "" {
|
||||
binders++
|
||||
}
|
||||
}
|
||||
if binders > 1 {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Only one extender can implement bind, found %v", binders))
|
||||
}
|
||||
return utilerrors.NewAggregate(validationErrors)
|
||||
}
|
||||
76
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation_test.go
generated
vendored
Normal file
76
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package validation
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
func TestValidatePolicy(t *testing.T) {
|
||||
tests := []struct {
|
||||
policy api.Policy
|
||||
expected error
|
||||
}{
|
||||
{
|
||||
policy: api.Policy{Priorities: []api.PriorityPolicy{{Name: "NoWeightPriority"}}},
|
||||
expected: errors.New("Priority NoWeightPriority should have a positive weight applied to it or it has overflown"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{Priorities: []api.PriorityPolicy{{Name: "NoWeightPriority", Weight: 0}}},
|
||||
expected: errors.New("Priority NoWeightPriority should have a positive weight applied to it or it has overflown"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{Priorities: []api.PriorityPolicy{{Name: "WeightPriority", Weight: 2}}},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
policy: api.Policy{Priorities: []api.PriorityPolicy{{Name: "WeightPriority", Weight: -2}}},
|
||||
expected: errors.New("Priority WeightPriority should have a positive weight applied to it or it has overflown"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{Priorities: []api.PriorityPolicy{{Name: "WeightPriority", Weight: api.MaxWeight}}},
|
||||
expected: errors.New("Priority WeightPriority should have a positive weight applied to it or it has overflown"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", FilterVerb: "filter", Weight: 2}}},
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
policy: api.Policy{ExtenderConfigs: []api.ExtenderConfig{{URLPrefix: "http://127.0.0.1:8081/extender", FilterVerb: "filter", Weight: -2}}},
|
||||
expected: errors.New("Priority for extender http://127.0.0.1:8081/extender should have a positive weight applied to it"),
|
||||
},
|
||||
{
|
||||
policy: api.Policy{
|
||||
ExtenderConfigs: []api.ExtenderConfig{
|
||||
{URLPrefix: "http://127.0.0.1:8081/extender", BindVerb: "bind", Weight: 2},
|
||||
{URLPrefix: "http://127.0.0.1:8082/extender", BindVerb: "bind", Weight: 2},
|
||||
}},
|
||||
expected: errors.New("Only one extender can implement bind, found 2"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
actual := ValidatePolicy(test.policy)
|
||||
if fmt.Sprint(test.expected) != fmt.Sprint(actual) {
|
||||
t.Errorf("expected: %s, actual: %s", test.expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue