k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/hack/_update-generated-protobuf-dockerized.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2015 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  # This script genertates `*/api.pb.go` from the protobuf file `*/api.proto`.
    18  # Usage: 
    19  #     hack/update-generated-protobuf-dockerized.sh "${APIROOTS[@]}"
    20  #     An example APIROOT is: "k8s.io/api/admissionregistration/v1"
    21  
    22  set -o errexit
    23  set -o nounset
    24  set -o pipefail
    25  
    26  KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
    27  source "${KUBE_ROOT}/hack/lib/init.sh"
    28  source "${KUBE_ROOT}/hack/lib/protoc.sh"
    29  
    30  kube::protoc::check_protoc
    31  kube::golang::setup_env
    32  
    33  GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf
    34  GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo
    35  
    36  # requires the 'proto' tag to build (will remove when ready)
    37  # searches for the protoc-gen-gogo extension in the output directory
    38  # satisfies import of github.com/gogo/protobuf/gogoproto/gogo.proto and the
    39  # core Google protobuf types
    40  PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
    41    go-to-protobuf \
    42    -v "${KUBE_VERBOSE}" \
    43    --go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
    44    --output-dir="${KUBE_ROOT}/staging/src" \
    45    --proto-import="${KUBE_ROOT}/staging/src" \
    46    --proto-import="${KUBE_ROOT}/vendor" `# required for gogo.proto` \
    47    --proto-import="${KUBE_ROOT}/third_party/protobuf" \
    48    --packages="$(IFS=, ; echo "$*")"