@@ -19,7 +19,7 @@ set -o nounset
19
19
set -o pipefail
20
20
21
21
# The root of the build/dist directory
22
- KUBE_ROOT=" $( cd " $( dirname " ${BASH_SOURCE} " ) /../.." && pwd -P) "
22
+ KUBE_ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0] } " ) /../.." && pwd -P) "
23
23
source " ${KUBE_ROOT} /hack/lib/init.sh"
24
24
25
25
# Generates $1/api.pb.go from the protobuf file $1/api.proto
@@ -35,8 +35,8 @@ function kube::protoc::generate_proto() {
35
35
kube::protoc::check_protoc
36
36
37
37
local package=${1}
38
- kube::protoc::protoc ${package}
39
- kube::protoc::format ${package}
38
+ kube::protoc::protoc " ${package} "
39
+ kube::protoc::format " ${package} "
40
40
}
41
41
42
42
# Checks that the current protoc version is at least version 3.0.0-beta1
@@ -62,7 +62,7 @@ function kube::protoc::protoc() {
62
62
PATH=" ${gogopath} :${PATH} " protoc \
63
63
--proto_path=" ${package} " \
64
64
--proto_path=" ${KUBE_ROOT} /vendor" \
65
- --gogo_out=plugins=grpc:${package} ${package} /api.proto
65
+ --gogo_out=plugins=grpc:" ${package} " " ${package} /api.proto"
66
66
}
67
67
68
68
# Formats $1/api.pb.go, adds the boilerplate comments and run gofmt on it
@@ -71,20 +71,20 @@ function kube::protoc::format() {
71
71
local package=${1}
72
72
73
73
# Update boilerplate for the generated file.
74
- echo " $( cat hack/boilerplate/boilerplate.generatego.txt ${package} /api.pb.go) " > ${package} /api.pb.go
74
+ cat hack/boilerplate/boilerplate.generatego.txt " ${package} /api.pb.go" > tmpfile && mv tmpfile " ${package} /api.pb.go"
75
75
76
76
# Run gofmt to clean up the generated code.
77
77
kube::golang::verify_go_version
78
- gofmt -l -s -w ${package} /api.pb.go
78
+ gofmt -l -s -w " ${package} /api.pb.go"
79
79
}
80
80
81
81
# Compares the contents of $1 and $2
82
82
# Echo's $3 in case of error and exits 1
83
83
function kube::protoc::diff() {
84
84
local ret=0
85
- diff -I " gzipped FileDescriptorProto" -I " 0x" -Naupr ${1} ${2} || ret=$?
85
+ diff -I " gzipped FileDescriptorProto" -I " 0x" -Naupr " ${1} " " ${2} " || ret=$?
86
86
if [[ ${ret} -ne 0 ]]; then
87
- echo ${3}
87
+ echo " ${3} "
88
88
exit 1
89
89
fi
90
90
}
0 commit comments