Remove kubectl's dependence on schema file in pkg/api/validation.

**What this PR does / why we need it**:

Makes functions in validation/schema.go private to kubectl,
further isolating kubectl.

**Which issue this PR fixes**

Part of a series of PRs to address kubernetes/community#598

**Release note**:
```release-note
NONE
```
This commit is contained in:
Jeffrey Regan
2017-05-23 10:29:19 -07:00
parent 929f138319
commit dbc22ad6fd
30 changed files with 320 additions and 69 deletions

121
hack/make-rules/BUILD Normal file
View File

@@ -0,0 +1,121 @@
# Scripts runnable from make, e.g.
#
# cd $GOPATH/src/k8s.io/kubernetes
# make test-e2e-node
#
# The sh_binary rules below exist only to validate
# dependencies; if a shell dependency is accidentally
# deleted, a presubmit BUILD will fail.
#
# If the scripts sourced their dependencies from
# $RUNFILES (rather than $BASH_SOURCE/../.. or
# whatever), then bazel build hack/... would install
# runnable, hermetically sealed shell "binaries".
# E.g. the following command would work:
#
# ./bazel-bin/hack/make-rules/test-e2e-node
#
# TODO(#47064): Should be a sh_test instead of sh_binary
sh_binary(
name = "test-cmd",
srcs = ["test-cmd.sh"],
deps = [
":test-cmd-util",
"//hack/lib",
],
)
sh_binary(
name = "test-e2e-node",
srcs = ["test-e2e-node.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "test-federation-cmd",
srcs = ["test-federation-cmd.sh"],
deps = [
":test-cmd-util",
"//hack/lib",
],
)
sh_binary(
name = "test-integration",
srcs = ["test-cmd.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "test-kubeadm-cmd",
srcs = ["test-kubeadm-cmd.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "build",
srcs = ["build.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "cross",
srcs = ["cross.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "test",
srcs = ["test.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "vet",
srcs = ["vet.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "verify",
srcs = ["verify.sh"],
deps = [
"//hack/lib",
],
)
sh_library(
name = "test-cmd-util",
srcs = [
"test-cmd-util.sh",
],
data = ["//pkg/kubectl/validation:testdata/v1/validPod.yaml"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

2
hack/make-rules/test-cmd-util.sh Normal file → Executable file
View File

@@ -687,7 +687,7 @@ run_pod_tests() {
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:'
## Patch can modify a local object
kubectl patch --local -f pkg/api/validation/testdata/v1/validPod.yaml --patch='{"spec": {"restartPolicy":"Never"}}' -o jsonpath='{.spec.restartPolicy}' | grep -q "Never"
kubectl patch --local -f pkg/kubectl/validation/testdata/v1/validPod.yaml --patch='{"spec": {"restartPolicy":"Never"}}' -o jsonpath='{.spec.restartPolicy}' | grep -q "Never"
## Patch pod can change image
# Command