forked from barak/tarpoon
Add glide.yaml and vendor deps
This commit is contained in:
parent
db918f12ad
commit
5b3d5e81bd
18880 changed files with 5166045 additions and 1 deletions
29
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/BUILD
generated
vendored
Normal file
29
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
"go_test",
|
||||
"cgo_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["validation.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/util/errors:go_default_library",
|
||||
"//plugin/pkg/scheduler/api:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["validation_test.go"],
|
||||
library = "go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = ["//plugin/pkg/scheduler/api:go_default_library"],
|
||||
)
|
||||
43
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation.go
generated
vendored
Normal file
43
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation.go
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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/kubernetes/pkg/util/errors"
|
||||
schedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
// Validate 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 {
|
||||
validationErrors := make([]error, 0)
|
||||
|
||||
for _, priority := range policy.Priorities {
|
||||
if priority.Weight <= 0 {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Priority %s should have a positive weight applied to it", priority.Name))
|
||||
}
|
||||
}
|
||||
|
||||
for _, extender := range policy.ExtenderConfigs {
|
||||
if extender.Weight < 0 {
|
||||
validationErrors = append(validationErrors, fmt.Errorf("Priority for extender %s should have a non negative weight applied to it", extender.URLPrefix))
|
||||
}
|
||||
}
|
||||
return utilerrors.NewAggregate(validationErrors)
|
||||
}
|
||||
52
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation_test.go
generated
vendored
Normal file
52
vendor/k8s.io/kubernetes/plugin/pkg/scheduler/api/validation/validation_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
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 (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
func TestValidatePriorityWithNoWeight(t *testing.T) {
|
||||
policy := api.Policy{Priorities: []api.PriorityPolicy{{Name: "NoWeightPriority"}}}
|
||||
if ValidatePolicy(policy) == nil {
|
||||
t.Errorf("Expected error about priority weight not being positive")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePriorityWithZeroWeight(t *testing.T) {
|
||||
policy := api.Policy{Priorities: []api.PriorityPolicy{{Name: "NoWeightPriority", Weight: 0}}}
|
||||
if ValidatePolicy(policy) == nil {
|
||||
t.Errorf("Expected error about priority weight not being positive")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePriorityWithNonZeroWeight(t *testing.T) {
|
||||
policy := api.Policy{Priorities: []api.PriorityPolicy{{Name: "WeightPriority", Weight: 2}}}
|
||||
errs := ValidatePolicy(policy)
|
||||
if errs != nil {
|
||||
t.Errorf("Unexpected errors %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePriorityWithNegativeWeight(t *testing.T) {
|
||||
policy := api.Policy{Priorities: []api.PriorityPolicy{{Name: "WeightPriority", Weight: -2}}}
|
||||
if ValidatePolicy(policy) == nil {
|
||||
t.Errorf("Expected error about priority weight not being positive")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue