2018-04-16 12:31:44 -04:00
|
|
|
#!/usr/bin/env bash
|
2015-11-26 18:13:55 -05:00
|
|
|
|
2016-06-02 20:25:58 -04:00
|
|
|
# Copyright 2015 The Kubernetes Authors.
|
2015-11-26 18:13:55 -05:00
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
|
2020-05-27 00:49:38 -04:00
|
|
|
# This script genertates `*/api.pb.go` from the protobuf file `*/api.proto`.
|
|
|
|
|
# Usage:
|
2023-01-14 00:41:23 -05:00
|
|
|
# hack/update-generated-protobuf-dockerized.sh "${APIROOTS[@]}"
|
2020-05-27 00:49:38 -04:00
|
|
|
# An example APIROOT is: "k8s.io/api/admissionregistration/v1"
|
|
|
|
|
|
2015-11-26 18:13:55 -05:00
|
|
|
set -o errexit
|
|
|
|
|
set -o nounset
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
2019-04-14 13:34:02 -04:00
|
|
|
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
2015-11-26 18:13:55 -05:00
|
|
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
2023-01-23 09:11:06 -05:00
|
|
|
source "${KUBE_ROOT}/hack/lib/protoc.sh"
|
2015-11-26 18:13:55 -05:00
|
|
|
|
2023-01-23 09:11:06 -05:00
|
|
|
kube::protoc::check_protoc
|
2023-12-29 16:29:04 -05:00
|
|
|
kube::golang::setup_env
|
2016-03-08 03:53:16 -05:00
|
|
|
|
2023-12-24 13:46:49 -05:00
|
|
|
GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf
|
|
|
|
|
GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo
|
2016-03-08 03:53:16 -05:00
|
|
|
|
2015-11-26 18:13:55 -05:00
|
|
|
# requires the 'proto' tag to build (will remove when ready)
|
|
|
|
|
# searches for the protoc-gen-gogo extension in the output directory
|
2016-05-12 02:55:21 -04:00
|
|
|
# satisfies import of github.com/gogo/protobuf/gogoproto/gogo.proto and the
|
|
|
|
|
# core Google protobuf types
|
2016-08-12 17:48:37 -04:00
|
|
|
PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
|
2024-01-12 19:23:23 -05:00
|
|
|
go-to-protobuf \
|
2023-12-24 13:46:49 -05:00
|
|
|
-v "${KUBE_VERBOSE}" \
|
|
|
|
|
--go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
|
2024-01-16 21:20:53 -05:00
|
|
|
--output-dir="${KUBE_ROOT}/staging/src" \
|
2023-12-24 13:46:49 -05:00
|
|
|
--proto-import="${KUBE_ROOT}/staging/src" \
|
|
|
|
|
--proto-import="${KUBE_ROOT}/vendor" `# required for gogo.proto` \
|
2016-06-12 18:05:17 -04:00
|
|
|
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
|
2023-12-24 13:46:49 -05:00
|
|
|
--packages="$(IFS=, ; echo "$*")"
|