Merge pull request #115238 from thockin/codegen-8-proto-bindings

Codegen: move all proto-bindings scripts together
This commit is contained in:
Kubernetes Prow Robot 2023-01-21 16:54:04 -08:00 committed by GitHub
commit 600e46801d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 90 additions and 731 deletions

View File

@ -56,10 +56,19 @@ function kube::protoc::protoc() {
local package=${1}
gogopath=$(dirname "$(kube::util::find-binary "protoc-gen-gogo")")
(
cd "${package}"
# This invocation of --gogo_out produces its output in the current
# directory (despite gogo docs saying it would be source-relative, it
# isn't). The inputs to this function do not all have a common root, so
# this works best for all inputs.
PATH="${gogopath}:${PATH}" protoc \
--proto_path="${package}" \
--proto_path="$(pwd -P)" \
--proto_path="${KUBE_ROOT}/vendor" \
--gogo_out=plugins=grpc:"${package}" "${package}/api.proto"
--gogo_out=paths=source_relative,plugins=grpc:. \
api.proto
)
}
# Formats $1/api.pb.go, adds the boilerplate comments and run gofmt on it
@ -72,7 +81,7 @@ function kube::protoc::format() {
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version
gofmt -l -s -w "${package}/api.pb.go"
gofmt -s -w "${package}/api.pb.go"
}
# Compares the contents of $1 and $2

View File

@ -38,9 +38,6 @@ fi
BASH_TARGETS=(
update-generated-protobuf
update-codegen
update-generated-runtime
update-generated-device-plugin
update-generated-dynamic-resource-allocation
update-generated-api-compatibility-data
update-generated-docs
update-generated-swagger-docs

View File

@ -777,6 +777,43 @@ function codegen::subprojects() {
done
}
function codegen::protobindings() {
# Each element of this array is a directory containing subdirectories which
# eventually contain a file named "api.proto".
local apis=(
"staging/src/k8s.io/cri-api/pkg/apis/runtime"
"staging/src/k8s.io/kubelet/pkg/apis/podresources"
"staging/src/k8s.io/kubelet/pkg/apis/deviceplugin"
"staging/src/k8s.io/kms/apis"
"staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2"
"staging/src/k8s.io/kubelet/pkg/apis/dra"
"staging/src/k8s.io/kubelet/pkg/apis/pluginregistration"
"pkg/kubelet/pluginmanager/pluginwatcher/example_plugin_apis"
)
kube::log::status "Generating protobuf bindings for ${#apis[@]} targets"
if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: generating protobuf bindings for:"
for dir in "${apis[@]}"; do
kube::log::status "DBG: $dir"
done
fi
for api in "${apis[@]}"; do
git ls-files -z -cmo --exclude-standard ":(glob)${api}"/'**/api.pb.go' \
| xargs -0 rm -f
done
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
build/run.sh hack/update-generated-proto-bindings-dockerized.sh "${apis[@]}"
}
#
# main

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-device-plugin-dockerized.sh "$@"

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script generates `*/api.pb.go` from the protobuf file `*/api.proto`.
# Example:
# kube::protoc::generate_proto "${DYNAMIC_RESOURCE_ALLOCATION_ALPHA}"
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)"
DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::protoc::generate_proto "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}"

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-dynamic-resource-allocation-dockerized.sh "$@"

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KUBE_KMS_V1BETA1="${KUBE_ROOT}/staging/src/k8s.io/kms/apis/v1beta1/"
KUBE_KMS_V2ALPHA1="${KUBE_ROOT}/staging/src/k8s.io/kms/apis/v2alpha1/"
KUBE_KMS_V2="${KUBE_ROOT}/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::protoc::generate_proto "${KUBE_KMS_V1BETA1}"
kube::protoc::generate_proto "${KUBE_KMS_V2ALPHA1}"
kube::protoc::generate_proto "${KUBE_KMS_V2}"

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-kms-dockerized.sh "$@"
# ex: ts=2 sw=2 et filetype=sh

View File

@ -1,39 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script generates `*/api.pb.go` from the protobuf file `*/api.proto`.
# Example:
# kube::protoc::generate_proto "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}"
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)"
dirs=(
"staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/"
"staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/"
"staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1/"
"pkg/kubelet/pluginmanager/pluginwatcher/example_plugin_apis/v1beta1/"
"pkg/kubelet/pluginmanager/pluginwatcher/example_plugin_apis/v1beta2/"
)
source "${KUBE_ROOT}/hack/lib/protoc.sh"
for d in "${dirs[@]}"; do
kube::protoc::generate_proto "${KUBE_ROOT}/${d}"
done

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-kubelet-plugin-registration-dockerized.sh "$@"

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script generates `*/api.pb.go` from the protobuf file `*/api.proto`.
# Example:
# kube::protoc::generate_proto "${POD_RESOURCES}"
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)"
dirs=(
"staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/"
"staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/"
)
source "${KUBE_ROOT}/hack/lib/protoc.sh"
for d in "${dirs[@]}"; do
kube::protoc::generate_proto "${KUBE_ROOT}/${d}"
done

View File

@ -1,32 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script generates `/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.pb.go`
# from the protobuf file `/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto`
# for pods.
# Usage: `hack/update-generated-pod-resources.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-pod-resources-dockerized.sh "$@"

View File

@ -14,18 +14,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This script generates `*/api.pb.go` from the protobuf file `*/api.proto`.
# Example:
# kube::protoc::generate_proto "${DEVICE_PLUGIN_ALPHA}"
# This script generates `*/api.pb.go` files from protobuf files `*/api.proto`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)"
DEVICE_PLUGIN_ALPHA="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/"
DEVICE_PLUGIN_V1BETA1="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::protoc::generate_proto "${DEVICE_PLUGIN_ALPHA}"
kube::protoc::generate_proto "${DEVICE_PLUGIN_V1BETA1}"
source "${KUBE_ROOT}/hack/lib/util.sh"
if [ "$#" == 0 ]; then
echo "usage: $0 <api_dir>..."
exit 1
fi
for api; do
# This can't use `git ls-files` because it runs in a container without the
# .git dir synced.
protos=()
kube::util::read-array protos < <( \
find "${api}" -type f -name "api.proto")
if [ "${#protos[@]}" == 0 ]; then
echo "ERROR: no 'api.proto' files under '${api}'"
exit 1
fi
for file in "${protos[@]}"; do
dir="$(dirname "${file}")"
kube::protoc::generate_proto "${dir}"
done
done

View File

@ -1,75 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script builds protoc-gen-gogo binary in runtime and genertates
# `*/api.pb.go` from the protobuf file `*/api.proto`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/"
source "${KUBE_ROOT}/hack/lib/init.sh"
runtime_versions=("v1")
kube::golang::setup_env
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
function cleanup {
for v in "${runtime_versions[@]}"; do
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/api.pb.go.bak"
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/api.pb.go.tmp"
done
}
trap cleanup EXIT
gogopath=$(dirname "$(kube::util::find-binary "protoc-gen-gogo")")
PATH="${gogopath}:${PATH}"
function generate_code() {
RUNTIME_API_VERSION="$1"
KUBE_REMOTE_RUNTIME_PATH="${KUBE_REMOTE_RUNTIME_ROOT}/${RUNTIME_API_VERSION}"
protoc \
--proto_path="${KUBE_REMOTE_RUNTIME_PATH}" \
--proto_path="${KUBE_ROOT}/vendor" \
--gogo_out=plugins=grpc:"${KUBE_ROOT}/staging/src" "${KUBE_REMOTE_RUNTIME_PATH}/api.proto"
# Update boilerplate for the generated file.
cat hack/boilerplate/boilerplate.generatego.txt "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" > "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go.tmp"
mv "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go.tmp" "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go"
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version
gofmt -l -s -w "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go"
}
for v in "${runtime_versions[@]}"; do
generate_code "${v}"
done

View File

@ -1,34 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script builds protoc-gen-gogo binary in runtime and genertates
# `*/api.pb.go` from the protobuf file `*/api.proto`.
# Usage:
# hack/update-generated-runtime.sh
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
"${KUBE_ROOT}/build/run.sh" hack/update-generated-runtime-dockerized.sh "$@"
# ex: ts=2 sw=2 et filetype=sh

View File

@ -1,50 +0,0 @@
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of device plugin API is needed or not. We
# should run `hack/update-generated-device-plugin.sh` if device plugin API is
# out of date.
# Usage: `hack/verify-generated-device-plugin.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
ERROR="Device plugin api is out of date. Please run hack/update-generated-device-plugin.sh"
DEVICE_PLUGIN_ALPHA="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/"
DEVICE_PLUGIN_V1BETA1="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::golang::setup_env
function cleanup {
rm -rf "${DEVICE_PLUGIN_ALPHA}/_tmp/"
rm -rf "${DEVICE_PLUGIN_V1BETA1}/_tmp/"
}
trap cleanup EXIT
mkdir -p "${DEVICE_PLUGIN_ALPHA}/_tmp"
cp "${DEVICE_PLUGIN_ALPHA}/api.pb.go" "${DEVICE_PLUGIN_ALPHA}/_tmp/"
mkdir -p "${DEVICE_PLUGIN_V1BETA1}/_tmp"
cp "${DEVICE_PLUGIN_V1BETA1}/api.pb.go" "${DEVICE_PLUGIN_V1BETA1}/_tmp/"
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-device-plugin.sh"
kube::protoc::diff "${DEVICE_PLUGIN_ALPHA}/api.pb.go" "${DEVICE_PLUGIN_ALPHA}/_tmp/api.pb.go" "${ERROR}"
echo "Generated device plugin alpha api is up to date."
kube::protoc::diff "${DEVICE_PLUGIN_V1BETA1}/api.pb.go" "${DEVICE_PLUGIN_V1BETA1}/_tmp/api.pb.go" "${ERROR}"
echo "Generated device plugin beta api is up to date."

View File

@ -1,44 +0,0 @@
#!/usr/bin/env bash
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of device plugin API is needed or not. We
# should run `hack/update-generated-dynamic-resource-allocation.sh` if device plugin API is
# out of date.
# Usage: `hack/verify-generated-dynamic-resource-allocation.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
ERROR="Dynamic resource allocation kubelet plugin api is out of date. Please run hack/update-generated-dynamic-resource-allocation.sh"
DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::golang::setup_env
function cleanup {
rm -rf "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/_tmp/"
}
trap cleanup EXIT
mkdir -p "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/_tmp"
cp "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/api.pb.go" "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/_tmp/"
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-dynamic-resource-allocation.sh"
kube::protoc::diff "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/api.pb.go" "${DYNAMIC_RESOURCE_ALLOCATION_V1ALPHA1}/_tmp/api.pb.go" "${ERROR}"
echo "Generated dynamic resource allocation kubelet plugin alpha api is up to date."

View File

@ -1,55 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of KMS gRPC is needed or not. We should
# run `hack/update-generated-kms.sh` if KMS gRPC is out of date.
# Usage: `hack/verify-generated-kms.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
ERROR="KMS gRPC is out of date. Please run hack/update-generated-kms.sh"
KUBE_KMS_V1BETA1="${KUBE_ROOT}/staging/src/k8s.io/kms/apis/v1beta1/"
KUBE_KMS_V2ALPHA1="${KUBE_ROOT}/staging/src/k8s.io/kms/apis/v2alpha1/"
KUBE_KMS_V2="${KUBE_ROOT}/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::golang::setup_env
function cleanup {
rm -rf "${KUBE_KMS_V1BETA1}/_tmp/"
rm -rf "${KUBE_KMS_V2ALPHA1}/_tmp/"
rm -rf "${KUBE_KMS_V2}/_tmp/"
}
trap cleanup EXIT
mkdir -p "${KUBE_KMS_V1BETA1}/_tmp"
cp "${KUBE_KMS_V1BETA1}/api.pb.go" "${KUBE_KMS_V1BETA1}/_tmp/"
mkdir -p "${KUBE_KMS_V2ALPHA1}/_tmp"
cp "${KUBE_KMS_V2ALPHA1}/api.pb.go" "${KUBE_KMS_V2ALPHA1}/_tmp/"
mkdir -p "${KUBE_KMS_V2}/_tmp"
cp "${KUBE_KMS_V2}/api.pb.go" "${KUBE_KMS_V2}/_tmp/"
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-kms.sh"
kube::protoc::diff "${KUBE_KMS_V1BETA1}/api.pb.go" "${KUBE_KMS_V1BETA1}/_tmp/api.pb.go" "${ERROR}"
echo "Generated kms v1beta1 api is up to date."
kube::protoc::diff "${KUBE_KMS_V2ALPHA1}/api.pb.go" "${KUBE_KMS_V2ALPHA1}/_tmp/api.pb.go" "${ERROR}"
echo "Generated kms v2alpha1 api is up to date."
kube::protoc::diff "${KUBE_KMS_V2}/api.pb.go" "${KUBE_KMS_V2}/_tmp/api.pb.go" "${ERROR}"
echo "Generated kms v2 api is up to date."

View File

@ -1,56 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of kubelet plugin registration API is
# needed or not. We should run
# `hack/update-generated-kubelet-plugin-registration.sh` if kubelet plugin
# registration API is out of date.
# Usage: `hack/verify-generated-kubelet-plugin-registration.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
ERROR="Kubelet Plugin Registration api is out of date. Please run hack/update-generated-kubelet-plugin-registration.sh"
KUBELET_PLUGIN_REGISTRATION_V1ALPHA="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/"
KUBELET_PLUGIN_REGISTRATION_V1BETA="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::golang::setup_env
function cleanup {
rm -rf "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/"
rm -rf "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/"
}
trap cleanup EXIT
mkdir -p "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp"
mkdir -p "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp"
cp "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/"
cp "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/"
# Check V1Alpha
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-kubelet-plugin-registration.sh"
kube::protoc::diff "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/api.pb.go" "${ERROR}"
echo "Generated Kubelet Plugin Registration api is up to date."
# Check V1Beta
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-kubelet-plugin-registration.sh"
kube::protoc::diff "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/api.pb.go" "${ERROR}"
echo "Generated Kubelet Plugin Registration api is up to date."

View File

@ -1,50 +0,0 @@
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of Pod resources API is needed or not. We
# should run `hack/update-generated-pod-resources.sh` if Pod resources API is
# out of date.
# Usage: `hack/verify-generated-pod-resources.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
POD_RESOURCES="${KUBE_ROOT}/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/"
source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
function cleanup {
rm -rf "${POD_RESOURCES}/_tmp/"
}
trap cleanup EXIT
mkdir -p "${POD_RESOURCES}/_tmp"
cp "${POD_RESOURCES}/api.pb.go" "${POD_RESOURCES}/_tmp/"
ret=0
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-pod-resources.sh"
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr "${POD_RESOURCES}/_tmp/api.pb.go" "${POD_RESOURCES}/api.pb.go" || ret=$?
if [[ $ret -eq 0 ]]; then
echo "Generated pod resources api is up to date."
cp "${POD_RESOURCES}/_tmp/api.pb.go" "${POD_RESOURCES}/"
else
echo "Generated pod resources api is out of date. Please run hack/update-generated-pod-resources.sh"
exit 1
fi

View File

@ -1,62 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script checks whether updating of container runtime API is needed or not.
# We should run `hack/update-generated-runtime.sh` if container runtime API is
# out of date.
# Usage: `hack/verify-generated-runtime.sh`.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/"
source "${KUBE_ROOT}/hack/lib/init.sh"
runtime_versions=("v1")
kube::golang::setup_env
function cleanup {
for v in "${runtime_versions[@]}"; do
rm -rf "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/_tmp/"
done
}
trap cleanup EXIT
function verify_generated_code() {
RUNTIME_API_VERSION="$1"
KUBE_REMOTE_RUNTIME_PATH="${KUBE_REMOTE_RUNTIME_ROOT}/${RUNTIME_API_VERSION}"
mkdir -p "${KUBE_REMOTE_RUNTIME_PATH}/_tmp"
cp "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/"
ret=0
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-runtime.sh"
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" || ret=$?
if [[ $ret -eq 0 ]]; then
echo "Generated container runtime api is up to date."
cp "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/"
else
echo "Generated container runtime api is out of date. Please run hack/update-generated-runtime.sh"
exit 1
fi
}
for v in "${runtime_versions[@]}"; do
verify_generated_code "${v}"
done

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// To regenerate api.pb.go run hack/update-generated-kms.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v2alpha1;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// To regenerate api.pb.go run hack/update-generated-runtime.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package runtime.v1;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// To regenerate api.pb.go run hack/update-generated-kms.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v1beta1;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// To regenerate api.pb.go run hack/update-generated-kms.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v2alpha1;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-device-plugin.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package deviceplugin;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-device-plugin.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v1beta1;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// To regenerate api.pb.go run hack/update-generated-kubelet-plugin-registration.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-kubelet-plugin-registration.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package pluginregistration;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-kubelet-plugin-registration.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package pluginregistration;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-kubelet-plugin-registration.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package pluginregistration;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-pod-resources.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v1;

View File

@ -1,4 +1,4 @@
// To regenerate api.pb.go run hack/update-generated-pod-resources.sh
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
syntax = "proto3";
package v1alpha1;