Skip to content

Commit 7987e3e

Browse files
committed
Update verify protobuf scripts
1 parent dbb76e9 commit 7987e3e

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

hack/update-protobuf.sh

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,10 @@
22

33
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
44

5-
[[ -n "${PROTO_OPTIONAL:-}" ]] && exit 0
6-
7-
if [ -z "${GOPATH:-}" ]; then
8-
echo "Generating protobuf requires GOPATH to be set. Please set GOPATH.
9-
To skip protobuf generation, set \$PROTO_OPTIONAL."
10-
exit 1
11-
fi
12-
13-
if [[ "$(protoc --version)" != "libprotoc 3."* ]]; then
14-
echo "Generating protobuf requires protoc 3.0.x. Please download and
15-
install the platform appropriate Protobuf package for your OS:
16-
17-
https://github.com/google/protobuf/releases
18-
19-
To skip protobuf generation, set \$PROTO_OPTIONAL."
20-
exit 1
21-
fi
22-
23-
# Build go-to-protobuf when it's not present and not overriden for a specific file.
24-
if [ -z "${GO_TO_PROTOBUF:-}" ]; then
25-
${TOOLS_MAKE} go-to-protobuf
26-
GO_TO_PROTOBUF="${TOOLS_OUTPUT}/go-to-protobuf"
27-
fi
28-
295
# Build protoc-gen-gogo when it's not present and not overriden for a specific file.
306
if [ -z "${PROTOC_GEN_GOGO:-}" ]; then
317
${TOOLS_MAKE} protoc-gen-gogo
328
PROTOC_GEN_GOGO="${TOOLS_OUTPUT}/protoc-gen-gogo"
339
fi
3410

35-
# We need to make sure that protoc-gen-gogo is on the path for go-to-protobuf to run correctly.
36-
protoc_bin_dir=$(dirname "${PROTOC_GEN_GOGO}")
37-
38-
PATH="$PATH:${protoc_bin_dir}" "${GO_TO_PROTOBUF}" \
39-
--output-base="${GOPATH}/src" \
40-
--apimachinery-packages='-k8s.io/apimachinery/pkg/util/intstr,-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/api/core/v1,-k8s.io/api/rbac/v1' \
41-
--go-header-file=${SCRIPT_ROOT}/hack/empty.txt \
42-
--proto-import=${SCRIPT_ROOT}/third_party/protobuf \
43-
--proto-import=${SCRIPT_ROOT}/vendor \
44-
--proto-import=${SCRIPT_ROOT}/tools/vendor \
45-
--packages="${API_PACKAGES}"
11+
GENERATOR=go-to-protobuf ${SCRIPT_ROOT}/hack/update-codegen.sh

hack/verify-protobuf.sh

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,10 @@
22

33
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
44

5-
TMP_ROOT="${SCRIPT_ROOT}/_tmp"
5+
# Build protoc-gen-gogo when it's not present and not overriden for a specific file.
6+
if [ -z "${PROTOC_GEN_GOGO:-}" ]; then
7+
${TOOLS_MAKE} protoc-gen-gogo
8+
PROTOC_GEN_GOGO="${TOOLS_OUTPUT}/protoc-gen-gogo"
9+
fi
610

7-
cleanup() {
8-
rm -rf "${TMP_ROOT}"
9-
}
10-
trap "cleanup" EXIT SIGINT
11-
12-
cleanup
13-
14-
for gv in ${API_GROUP_VERSIONS}; do
15-
mkdir -p "${TMP_ROOT}/${gv}"
16-
cp -a --no-preserve=timestamp "${SCRIPT_ROOT}/${gv}"/* "${TMP_ROOT}/${gv}"
17-
done
18-
19-
"${SCRIPT_ROOT}/hack/update-protobuf.sh"
20-
echo "Checking against freshly generated protobuf..."
21-
for gv in ${API_GROUP_VERSIONS}; do
22-
ret=0
23-
diff -Naupr -I 'Auto generated by' -x 'zz_generated.*' -x 'types_swagger*' "${SCRIPT_ROOT}/${gv}" "${TMP_ROOT}/${gv}" || ret=$?
24-
if [[ $ret -ne 0 ]]; then
25-
cp -a --no-preserve=timestamp "${TMP_ROOT}"/* "${SCRIPT_ROOT}/"
26-
echo "Protobuf is out of date. Please run hack/update-protobuf.sh"
27-
exit 1
28-
fi
29-
done
30-
echo "Protobuf up to date."
11+
GENERATOR=go-to-protobuf EXTRA_ARGS=--verify ${SCRIPT_ROOT}/hack/update-codegen.sh

0 commit comments

Comments
 (0)