Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shellcheck failures of hack/update-generated-kms-dockerized.sh and hack/update-generated-protobuf-dockerized.sh #76478

Merged
merged 1 commit into from Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions hack/.shellcheck_failures
Expand Up @@ -42,8 +42,6 @@
./hack/make-rules/vet.sh
./hack/test-integration.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-openapi-spec.sh
./hack/update-vendor.sh
Expand Down
14 changes: 8 additions & 6 deletions hack/update-generated-kms-dockerized.sh
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
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/"
source "${KUBE_ROOT}/hack/lib/init.sh"

Expand All @@ -40,22 +40,24 @@ if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then
fi

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

gogopath=$(dirname $(kube::util::find-binary "protoc-gen-gogo"))
gogopath=$(dirname "$(kube::util::find-binary "protoc-gen-gogo")")

PATH="${gogopath}:${PATH}" \
protoc \
--proto_path="${KUBE_KMS_GRPC_ROOT}" \
--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.
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" && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would separate these into two lines, no need to use &&

mv "${KUBE_KMS_GRPC_ROOT}/service.pb.go.tmp" "${KUBE_KMS_GRPC_ROOT}/service.pb.go"

# Run gofmt to clean up the generated code.
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"
10 changes: 6 additions & 4 deletions hack/update-generated-protobuf-dockerized.sh
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"

kube::golang::setup_env
Expand All @@ -41,7 +41,9 @@ fi

gotoprotobuf=$(kube::util::find-binary "go-to-protobuf")

APIROOTS=( ${1} )
while IFS=$'\n' read -r line; do
APIROOTS+=( "$line" );
done <<< "${1}"
shift

# requires the 'proto' tag to build (will remove when ready)
Expand All @@ -52,6 +54,6 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
"${gotoprotobuf}" \
--proto-import="${KUBE_ROOT}/vendor" \
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
--packages=$(IFS=, ; echo "${APIROOTS[*]}") \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \
--packages="$(IFS=, ; echo "${APIROOTS[*]}")" \
--go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
"$@"