Use kube-openapi cmd in Make rules

check in existing API rule violations;
the Make rule fails if generated violation report differs from the
checked-in violation file and prints error message;
add documentation.
This commit is contained in:
Haowei Cai
2018-07-10 17:53:24 -07:00
parent 3cd919c9fb
commit 3af6061e76
6 changed files with 143 additions and 8 deletions

View File

@@ -38,15 +38,17 @@ def openapi_library(name, tags, srcs, go_prefix, vendor_prefix = "", openapi_tar
cmd = " ".join([
"ORIG_WD=$$(pwd);",
"cd $$GOPATH/src/" + go_prefix + ";",
"$$ORIG_WD/$(location //vendor/k8s.io/code-generator/cmd/openapi-gen)",
"$$ORIG_WD/$(location //vendor/k8s.io/kube-openapi/cmd/openapi-gen)",
"--v 1",
"--logtostderr",
"--go-header-file $$ORIG_WD/$(location //" + vendor_prefix + "hack/boilerplate:boilerplate.go.txt)",
"--output-file-base zz_generated.openapi",
"--output-package " + go_prefix + "pkg/generated/openapi",
"--report-filename tmp_api_violations.report",
"--input-dirs " + ",".join([go_prefix + target for target in openapi_targets] + [go_prefix + "vendor/" + target for target in vendor_targets]),
"&& cp $$GOPATH/src/" + go_prefix + "pkg/generated/openapi/zz_generated.openapi.go $$ORIG_WD/$(location :zz_generated.openapi.go)",
"&& rm tmp_api_violations.report",
]),
go_deps = deps,
tools = ["//vendor/k8s.io/code-generator/cmd/openapi-gen"],
tools = ["//vendor/k8s.io/kube-openapi/cmd/openapi-gen"],
)