From ea02ce5b60338a2a928f17a128a5af93df67520b Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 29 Jul 2025 09:21:43 +0200 Subject: [PATCH] Update protobindings scripts to drop gogo paths Cleanup the available scripts to remove unused code paths after all gogo references have been migrated to native protobuf. Signed-off-by: Sascha Grunert --- ...ate-generated-proto-bindings-dockerized.sh | 16 +------- hack/lib/protoc.sh | 37 ------------------- hack/update-codegen.sh | 4 +- 3 files changed, 4 insertions(+), 53 deletions(-) diff --git a/hack/_update-generated-proto-bindings-dockerized.sh b/hack/_update-generated-proto-bindings-dockerized.sh index 9c7a7d28822..55cb70a650d 100755 --- a/hack/_update-generated-proto-bindings-dockerized.sh +++ b/hack/_update-generated-proto-bindings-dockerized.sh @@ -27,12 +27,10 @@ source "${KUBE_ROOT}/hack/lib/protoc.sh" source "${KUBE_ROOT}/hack/lib/util.sh" if (( $# < 2 )); then - echo "usage: $0 [gogo|protoc] ..." + echo "usage: $0 ..." exit 1 fi -generator=$1; shift - kube::protoc::check_protoc for api; do @@ -49,16 +47,6 @@ for api; do for file in "${protos[@]}"; do dir="$(dirname "${file}")" - case "${generator}" in - gogo) - kube::protoc::generate_proto_gogo "${dir}" - ;; - protoc) - kube::protoc::generate_proto "${dir}" - ;; - *) - echo "Unknown generator ${generator}" >&2 - exit 1 - esac + kube::protoc::generate_proto "${dir}" done done diff --git a/hack/lib/protoc.sh b/hack/lib/protoc.sh index 304d71bbbbc..3a49a92d846 100644 --- a/hack/lib/protoc.sh +++ b/hack/lib/protoc.sh @@ -42,20 +42,6 @@ function kube::protoc::generate_proto() { kube::protoc::format "${package}" } -# 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 -function kube::protoc::generate_proto_gogo() { - kube::golang::setup_env - GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo - - kube::protoc::check_protoc - - local package=${1} - kube::protoc::protoc_gogo "${package}" - kube::protoc::format "${package}" -} - # Checks that the current protoc version matches the required version and # exit 1 if it's not the case function kube::protoc::check_protoc() { @@ -70,29 +56,6 @@ function kube::protoc::check_protoc() { # Generates $1/api.pb.go from the protobuf file $1/api.proto # $1: Full path to the directory where the api.proto file is -function kube::protoc::protoc_gogo() { - 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="$(pwd -P)" \ - --proto_path="${KUBE_ROOT}/vendor" \ - --proto_path="${KUBE_ROOT}/staging/src" \ - --proto_path="${KUBE_ROOT}/third_party/protobuf" \ - --gogo_out=paths=source_relative,plugins=grpc:. \ - api.proto - ) -} - -# Generates $1/api.pb.go from the protobuf file $1/api.proto without using gogo -# $1: Full path to the directory where the api.proto file is function kube::protoc::protoc() { local package=${1} diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 13b9f46a642..4cae836dc06 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -1047,13 +1047,13 @@ function codegen::protobindings() { done if kube::protoc::check_protoc >/dev/null; then - hack/_update-generated-proto-bindings-dockerized.sh protoc "${apis[@]}" + hack/_update-generated-proto-bindings-dockerized.sh "${apis[@]}" else kube::log::status "protoc ${PROTOC_VERSION} not found (can install with hack/install-protoc.sh); generating containerized..." # 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 protoc "${apis[@]}" + build/run.sh hack/_update-generated-proto-bindings-dockerized.sh "${apis[@]}" fi }