fix shellcheck failures of hack/update-generated-kms-dockerized.sh hack/update-generated-protobuf-dockerized.sh

This commit is contained in:
SataQiu 2019-04-15 01:34:02 +08:00
parent 0a59758c58
commit db8bc68946
3 changed files with 14 additions and 12 deletions

View File

@ -42,8 +42,6 @@
./hack/make-rules/vet.sh ./hack/make-rules/vet.sh
./hack/test-integration.sh ./hack/test-integration.sh
./hack/test-update-storage-objects.sh ./hack/test-update-storage-objects.sh
./hack/update-generated-kms-dockerized.sh
./hack/update-generated-protobuf-dockerized.sh
./hack/update-generated-runtime-dockerized.sh ./hack/update-generated-runtime-dockerized.sh
./hack/update-openapi-spec.sh ./hack/update-openapi-spec.sh
./hack/update-vendor.sh ./hack/update-vendor.sh

View File

@ -18,7 +18,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KUBE_KMS_GRPC_ROOT="${KUBE_ROOT}/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/" KUBE_KMS_GRPC_ROOT="${KUBE_ROOT}/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/v1beta1/"
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
@ -40,22 +40,24 @@ if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then
fi fi
function cleanup { function cleanup {
rm -f ${KUBE_KMS_GRPC_ROOT}/service.pb.go.bak rm -f "${KUBE_KMS_GRPC_ROOT}/service.pb.go.bak"
rm -f "${KUBE_KMS_GRPC_ROOT}/service.pb.go.tmp"
} }
trap cleanup EXIT trap cleanup EXIT
gogopath=$(dirname $(kube::util::find-binary "protoc-gen-gogo")) gogopath=$(dirname "$(kube::util::find-binary "protoc-gen-gogo")")
PATH="${gogopath}:${PATH}" \ PATH="${gogopath}:${PATH}" \
protoc \ protoc \
--proto_path="${KUBE_KMS_GRPC_ROOT}" \ --proto_path="${KUBE_KMS_GRPC_ROOT}" \
--proto_path="${KUBE_ROOT}/vendor" \ --proto_path="${KUBE_ROOT}/vendor" \
--gogo_out=plugins=grpc:${KUBE_KMS_GRPC_ROOT} ${KUBE_KMS_GRPC_ROOT}/service.proto --gogo_out=plugins=grpc:"${KUBE_KMS_GRPC_ROOT}" "${KUBE_KMS_GRPC_ROOT}/service.proto"
# Update boilerplate for the generated file. # Update boilerplate for the generated file.
echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${KUBE_KMS_GRPC_ROOT}/service.pb.go)" > ${KUBE_KMS_GRPC_ROOT}/service.pb.go cat hack/boilerplate/boilerplate.generatego.txt "${KUBE_KMS_GRPC_ROOT}/service.pb.go" > "${KUBE_KMS_GRPC_ROOT}/service.pb.go.tmp" && \
mv "${KUBE_KMS_GRPC_ROOT}/service.pb.go.tmp" "${KUBE_KMS_GRPC_ROOT}/service.pb.go"
# Run gofmt to clean up the generated code. # Run gofmt to clean up the generated code.
kube::golang::verify_go_version kube::golang::verify_go_version
gofmt -l -s -w ${KUBE_KMS_GRPC_ROOT}/service.pb.go gofmt -l -s -w "${KUBE_KMS_GRPC_ROOT}/service.pb.go"

View File

@ -18,7 +18,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env kube::golang::setup_env
@ -41,7 +41,9 @@ fi
gotoprotobuf=$(kube::util::find-binary "go-to-protobuf") gotoprotobuf=$(kube::util::find-binary "go-to-protobuf")
APIROOTS=( ${1} ) while IFS=$'\n' read -r line; do
APIROOTS+=( "$line" );
done <<< "${1}"
shift shift
# requires the 'proto' tag to build (will remove when ready) # requires the 'proto' tag to build (will remove when ready)
@ -52,6 +54,6 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
"${gotoprotobuf}" \ "${gotoprotobuf}" \
--proto-import="${KUBE_ROOT}/vendor" \ --proto-import="${KUBE_ROOT}/vendor" \
--proto-import="${KUBE_ROOT}/third_party/protobuf" \ --proto-import="${KUBE_ROOT}/third_party/protobuf" \
--packages=$(IFS=, ; echo "${APIROOTS[*]}") \ --packages="$(IFS=, ; echo "${APIROOTS[*]}")" \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \ --go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
"$@" "$@"