diff --git a/hack/lib/protoc.sh b/hack/lib/protoc.sh index 7d4174a4565..d03eed4e9ed 100644 --- a/hack/lib/protoc.sh +++ b/hack/lib/protoc.sh @@ -72,7 +72,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 diff --git a/hack/make-rules/update.sh b/hack/make-rules/update.sh index a1ea51ce530..61b404bf5e1 100755 --- a/hack/make-rules/update.sh +++ b/hack/make-rules/update.sh @@ -39,8 +39,7 @@ BASH_TARGETS=( update-generated-protobuf update-codegen update-generated-runtime - update-generated-device-plugin - update-generated-dynamic-resource-allocation + update-generated-proto-bindings update-generated-api-compatibility-data update-generated-docs update-generated-swagger-docs diff --git a/hack/update-generated-device-plugin-dockerized.sh b/hack/update-generated-device-plugin-dockerized.sh deleted file mode 100755 index 3f507511d2f..00000000000 --- a/hack/update-generated-device-plugin-dockerized.sh +++ /dev/null @@ -1,31 +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 "${DEVICE_PLUGIN_ALPHA}" - -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}" diff --git a/hack/update-generated-dynamic-resource-allocation-dockerized.sh b/hack/update-generated-dynamic-resource-allocation-dockerized.sh deleted file mode 100755 index ad9f75f114d..00000000000 --- a/hack/update-generated-dynamic-resource-allocation-dockerized.sh +++ /dev/null @@ -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}" diff --git a/hack/update-generated-dynamic-resource-allocation.sh b/hack/update-generated-dynamic-resource-allocation.sh deleted file mode 100755 index d20db5edb5e..00000000000 --- a/hack/update-generated-dynamic-resource-allocation.sh +++ /dev/null @@ -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 "$@" diff --git a/hack/update-generated-kms-dockerized.sh b/hack/update-generated-kms-dockerized.sh deleted file mode 100755 index 15d794ea7bd..00000000000 --- a/hack/update-generated-kms-dockerized.sh +++ /dev/null @@ -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}" diff --git a/hack/update-generated-kms.sh b/hack/update-generated-kms.sh deleted file mode 100755 index 6ae29450d0c..00000000000 --- a/hack/update-generated-kms.sh +++ /dev/null @@ -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 diff --git a/hack/update-generated-kubelet-plugin-registration-dockerized.sh b/hack/update-generated-kubelet-plugin-registration-dockerized.sh deleted file mode 100755 index e3ead0696a1..00000000000 --- a/hack/update-generated-kubelet-plugin-registration-dockerized.sh +++ /dev/null @@ -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 diff --git a/hack/update-generated-kubelet-plugin-registration.sh b/hack/update-generated-kubelet-plugin-registration.sh deleted file mode 100755 index 46e3d1f8c83..00000000000 --- a/hack/update-generated-kubelet-plugin-registration.sh +++ /dev/null @@ -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 "$@" diff --git a/hack/update-generated-pod-resources-dockerized.sh b/hack/update-generated-pod-resources-dockerized.sh deleted file mode 100755 index a477e6e3b8d..00000000000 --- a/hack/update-generated-pod-resources-dockerized.sh +++ /dev/null @@ -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 - diff --git a/hack/update-generated-pod-resources.sh b/hack/update-generated-pod-resources.sh deleted file mode 100755 index c51a156064d..00000000000 --- a/hack/update-generated-pod-resources.sh +++ /dev/null @@ -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 "$@" diff --git a/hack/update-generated-proto-bindings-dockerized.sh b/hack/update-generated-proto-bindings-dockerized.sh new file mode 100755 index 00000000000..c9f7352ca96 --- /dev/null +++ b/hack/update-generated-proto-bindings-dockerized.sh @@ -0,0 +1,51 @@ +#!/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` files from protobuf files `*/api.proto`. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd -P)" + +source "${KUBE_ROOT}/hack/lib/protoc.sh" + +# Each element of this array is a directory containing subdirectories which +# eventually contain a file named "api.proto". +APIS=( + "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" +) + +for api in "${APIS[@]}"; do + # This can't use `git ls-files` because it runs in a container without the + # .git dir synced. + find "${api}" -type f -name "api.proto" \ + | while read -r F; do + D="$(dirname "${F}")" + kube::protoc::generate_proto "${KUBE_ROOT}/${D}" + done +done diff --git a/hack/update-generated-device-plugin.sh b/hack/update-generated-proto-bindings.sh similarity index 91% rename from hack/update-generated-device-plugin.sh rename to hack/update-generated-proto-bindings.sh index 6652500887f..87bdee7fe14 100755 --- a/hack/update-generated-device-plugin.sh +++ b/hack/update-generated-proto-bindings.sh @@ -24,4 +24,4 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. # 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 "$@" +"${KUBE_ROOT}/build/run.sh" hack/update-generated-proto-bindings-dockerized.sh diff --git a/hack/verify-generated-device-plugin.sh b/hack/verify-generated-device-plugin.sh deleted file mode 100755 index 88118821761..00000000000 --- a/hack/verify-generated-device-plugin.sh +++ /dev/null @@ -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." diff --git a/hack/verify-generated-dynamic-resource-allocation.sh b/hack/verify-generated-dynamic-resource-allocation.sh deleted file mode 100755 index 3f38cbf5671..00000000000 --- a/hack/verify-generated-dynamic-resource-allocation.sh +++ /dev/null @@ -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." diff --git a/hack/verify-generated-kms.sh b/hack/verify-generated-kms.sh deleted file mode 100755 index 632e4dd6cde..00000000000 --- a/hack/verify-generated-kms.sh +++ /dev/null @@ -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." diff --git a/hack/verify-generated-kubelet-plugin-registration.sh b/hack/verify-generated-kubelet-plugin-registration.sh deleted file mode 100755 index 07b2f2af7c7..00000000000 --- a/hack/verify-generated-kubelet-plugin-registration.sh +++ /dev/null @@ -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." diff --git a/hack/verify-generated-pod-resources.sh b/hack/verify-generated-pod-resources.sh deleted file mode 100755 index 46e7442964f..00000000000 --- a/hack/verify-generated-pod-resources.sh +++ /dev/null @@ -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 diff --git a/hack/verify-generated-proto-bindings.sh b/hack/verify-generated-proto-bindings.sh new file mode 100755 index 00000000000..b0ae55b52f4 --- /dev/null +++ b/hack/verify-generated-proto-bindings.sh @@ -0,0 +1,49 @@ +#!/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 protobuf bindings is needed. +# Run `hack/update-generated-proto-bindings.sh` to regenerate them. +# +# Usage: `hack/verify-generated-proto-bindings.sh`. + + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${KUBE_ROOT}/hack/lib/init.sh" + +kube::util::ensure_clean_working_dir + +_tmpdir="$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")" +git worktree add -f -q "${_tmpdir}" HEAD +kube::util::trap_add "git worktree remove -f ${_tmpdir}" EXIT +cd "${_tmpdir}" + +# Regenerate. +hack/update-generated-proto-bindings.sh + +# Test for diffs +diffs=$(git status --porcelain | wc -l) +if [[ ${diffs} -gt 0 ]]; then + git status + git diff + echo + echo "Proto bindings need to be regenerated" >&2 + echo "Please run 'hack/update-generated-proto-bindings.sh'" >&2 + exit 1 +fi diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/api.proto b/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/api.proto index e3b978b05ed..33176d2b00a 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/api.proto +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2/v2alpha1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package v2alpha1; diff --git a/staging/src/k8s.io/kms/apis/v1beta1/api.proto b/staging/src/k8s.io/kms/apis/v1beta1/api.proto index a9b44bf5fa1..b6576b2d242 100644 --- a/staging/src/k8s.io/kms/apis/v1beta1/api.proto +++ b/staging/src/k8s.io/kms/apis/v1beta1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package v1beta1; diff --git a/staging/src/k8s.io/kms/apis/v2alpha1/api.proto b/staging/src/k8s.io/kms/apis/v2alpha1/api.proto index 9b960b2acc4..eaf77077d5c 100644 --- a/staging/src/k8s.io/kms/apis/v2alpha1/api.proto +++ b/staging/src/k8s.io/kms/apis/v2alpha1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package v2alpha1; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/api.proto index 13ad6e7ff5d..61809b14253 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1alpha/api.proto @@ -1,4 +1,4 @@ -// To regenerate api.pb.go run hack/update-generated-device-plugin.sh +// To regenerate api.pb.go run hack/update-generated-proto-bindings.sh syntax = "proto3"; package deviceplugin; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/api.proto index d22da05b2a0..a907a84a2e5 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/api.proto @@ -1,4 +1,4 @@ -// To regenerate api.pb.go run hack/update-generated-device-plugin.sh +// To regenerate api.pb.go run hack/update-generated-proto-bindings.sh syntax = "proto3"; package v1beta1; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/api.proto index 2ba5c5c34d4..c86ef6928e0 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; @@ -78,4 +78,4 @@ message NodeUnprepareResourceRequest { message NodeUnprepareResourceResponse { // Intentionally empty. -} \ No newline at end of file +} diff --git a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1/api.proto index 5c4f6f80168..03bab1af856 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package pluginregistration; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/api.proto index 5c4f6f80168..03bab1af856 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1alpha1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package pluginregistration; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/api.proto index 5c4f6f80168..03bab1af856 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/pluginregistration/v1beta1/api.proto @@ -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-generated-proto-bindings.sh syntax = "proto3"; package pluginregistration; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto index add2aad4874..40427bb5bbc 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto @@ -1,4 +1,4 @@ -// To regenerate api.pb.go run hack/update-generated-pod-resources.sh +// To regenerate api.pb.go run hack/update-generated-proto-bindings.sh syntax = "proto3"; package v1; diff --git a/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto index 782ac714b6a..6d74b6ba493 100644 --- a/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto +++ b/staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto @@ -1,4 +1,4 @@ -// To regenerate api.pb.go run hack/update-generated-pod-resources.sh +// To regenerate api.pb.go run hack/update-generated-proto-bindings.sh syntax = "proto3"; package v1alpha1; @@ -45,4 +45,4 @@ message ContainerResources { message ContainerDevices { string resource_name = 1; repeated string device_ids = 2; -} \ No newline at end of file +}