mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 01:40:13 +00:00
Check protoc version strictly
This commit is contained in:
parent
f21c603417
commit
238e0226db
@ -53,6 +53,13 @@ dependencies:
|
||||
- path: cluster/gce/gci/configure.sh
|
||||
match: DEFAULT_CRICTL_VERSION=
|
||||
|
||||
# protoc
|
||||
- name: "protoc"
|
||||
version: 3.19.4
|
||||
refPaths:
|
||||
- path: hack/lib/protoc.sh
|
||||
match: PROTOC_VERSION=
|
||||
|
||||
# etcd
|
||||
- name: "etcd"
|
||||
version: 3.5.6
|
||||
|
@ -22,6 +22,8 @@ set -o pipefail
|
||||
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
PROTOC_VERSION=3.19.4
|
||||
|
||||
# Generates $1/api.pb.go from the protobuf file $1/api.proto
|
||||
# and formats it correctly
|
||||
# $1: Full path to the directory where the api.proto file is
|
||||
@ -36,17 +38,15 @@ function kube::protoc::generate_proto() {
|
||||
kube::protoc::format "${package}"
|
||||
}
|
||||
|
||||
# Checks that the current protoc version is at least version 3.0.0-beta1
|
||||
# Checks that the current protoc version matches the required version and
|
||||
# exit 1 if it's not the case
|
||||
function kube::protoc::check_protoc() {
|
||||
if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then
|
||||
echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
|
||||
echo "install the platform appropriate Protobuf package for your OS: "
|
||||
echo
|
||||
echo " https://github.com/protocolbuffers/protobuf/releases"
|
||||
echo
|
||||
echo "WARNING: Protobuf changes are not being validated"
|
||||
exit 1
|
||||
if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc ${PROTOC_VERSION}"* ]]; then
|
||||
echo "Generating protobuf requires protoc ${PROTOC_VERSION}."
|
||||
echo "Run hack/install-protoc.sh or download and install the"
|
||||
echo "platform-appropriate Protobuf package for your OS from"
|
||||
echo "https://github.com/protocolbuffers/protobuf/releases"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ set -o pipefail
|
||||
|
||||
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)"
|
||||
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/protoc.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/util.sh"
|
||||
|
||||
@ -30,6 +31,8 @@ if [ "$#" == 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kube::protoc::check_protoc
|
||||
|
||||
for api; do
|
||||
# This can't use `git ls-files` because it runs in a container without the
|
||||
# .git dir synced.
|
||||
|
@ -25,22 +25,14 @@ set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/protoc.sh"
|
||||
|
||||
kube::protoc::check_protoc
|
||||
kube::golang::setup_env
|
||||
|
||||
GO111MODULE=on GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf
|
||||
GO111MODULE=on GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo
|
||||
|
||||
if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then
|
||||
echo "Generating protobuf requires protoc 3.0.0-beta1 or newer. Please download and"
|
||||
echo "install the platform appropriate Protobuf package for your OS: "
|
||||
echo
|
||||
echo " https://github.com/protocolbuffers/protobuf/releases"
|
||||
echo
|
||||
echo "WARNING: Protobuf changes are not being validated"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gotoprotobuf=$(kube::util::find-binary "go-to-protobuf")
|
||||
|
||||
# requires the 'proto' tag to build (will remove when ready)
|
||||
|
Loading…
Reference in New Issue
Block a user