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