move helpers.go to helper

This commit is contained in:
Chao Xu
2017-04-10 10:49:54 -07:00
parent c68ae58c93
commit 08aa712a6c
67 changed files with 974 additions and 903 deletions

View File

@@ -17,6 +17,7 @@ go_library(
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/helper:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/util/validation/field",
],
)
@@ -26,7 +27,10 @@ go_test(
srcs = ["mustmatchpatterns_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = ["//pkg/api:go_default_library"],
deps = [
"//pkg/api:go_default_library",
"//pkg/api/helper:go_default_library",
],
)
filegroup(

View File

@@ -22,6 +22,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
)
// mustMatchPatterns implements the CapabilitiesStrategy interface
@@ -59,7 +60,7 @@ func (s *mustMatchPatterns) validateAnnotation(pod *api.Pod, key string) field.E
fieldPath := field.NewPath("pod", "metadata", "annotations").Key(key)
sysctls, err := api.SysctlsFromPodAnnotation(pod.Annotations[key])
sysctls, err := helper.SysctlsFromPodAnnotation(pod.Annotations[key])
if err != nil {
allErrs = append(allErrs, field.Invalid(fieldPath, pod.Annotations[key], err.Error()))
}

View File

@@ -20,6 +20,7 @@ import (
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
)
func TestValidate(t *testing.T) {
@@ -75,7 +76,7 @@ func TestValidate(t *testing.T) {
}
testAllowed := func(key string, category string) {
pod.Annotations = map[string]string{
key: api.PodAnnotationsFromSysctls(sysctls),
key: helper.PodAnnotationsFromSysctls(sysctls),
}
errs = strategy.Validate(pod)
if len(errs) != 0 {
@@ -85,7 +86,7 @@ func TestValidate(t *testing.T) {
testDisallowed := func(key string, category string) {
for _, s := range v.disallowed {
pod.Annotations = map[string]string{
key: api.PodAnnotationsFromSysctls([]api.Sysctl{{Name: s, Value: "dummy"}}),
key: helper.PodAnnotationsFromSysctls([]api.Sysctl{{Name: s, Value: "dummy"}}),
}
errs = strategy.Validate(pod)
if len(errs) == 0 {