@@ -56,12 +56,23 @@ function kube::release::parse_and_validate_ci_version() {
56
56
kube::log::error " Invalid ci version: '${version} ', must match regex ${version_regex} "
57
57
return 1
58
58
}
59
+
60
+ # The VERSION variables are used when this file is sourced, hence
61
+ # the shellcheck SC2034 'appears unused' warning is to be ignored.
62
+
63
+ # shellcheck disable=SC2034
59
64
VERSION_MAJOR=" ${BASH_REMATCH[1]} "
65
+ # shellcheck disable=SC2034
60
66
VERSION_MINOR=" ${BASH_REMATCH[2]} "
67
+ # shellcheck disable=SC2034
61
68
VERSION_PATCH=" ${BASH_REMATCH[3]} "
69
+ # shellcheck disable=SC2034
62
70
VERSION_PRERELEASE=" ${BASH_REMATCH[4]} "
71
+ # shellcheck disable=SC2034
63
72
VERSION_PRERELEASE_REV=" ${BASH_REMATCH[5]} "
73
+ # shellcheck disable=SC2034
64
74
VERSION_BUILD_INFO=" ${BASH_REMATCH[6]} "
75
+ # shellcheck disable=SC2034
65
76
VERSION_COMMITS=" ${BASH_REMATCH[7]} "
66
77
}
67
78
@@ -97,31 +108,30 @@ function kube::release::package_tarballs() {
97
108
function kube::release::package_src_tarball() {
98
109
local -r src_tarball=" ${RELEASE_TARS} /kubernetes-src.tar.gz"
99
110
kube::log::status " Building tarball: src"
100
- if [[ " ${KUBE_GIT_TREE_STATE-} " == " clean" ]]; then
111
+ if [[ " ${KUBE_GIT_TREE_STATE-} " = ' clean' ]]; then
101
112
git archive -o " ${src_tarball} " HEAD
102
113
else
103
- local source_files=(
104
- $( cd " ${KUBE_ROOT} " && find . -mindepth 1 -maxdepth 1 \
105
- -not \( \
106
- \( -path ./_\* -o \
107
- -path ./.git\* -o \
108
- -path ./.config\* -o \
109
- -path ./.gsutil\* \
110
- \) -prune \
111
- \) )
112
- )
113
- " ${TAR} " czf " ${src_tarball} " --transform ' s|^\.|kubernetes|' -C " ${KUBE_ROOT} " " ${source_files[@]} "
114
+ find " ${KUBE_ROOT} " -mindepth 1 -maxdepth 1 \
115
+ ! \( \
116
+ \( -path " ${KUBE_ROOT} " /_\* -o \
117
+ -path " ${KUBE_ROOT} " /.git\* -o \
118
+ -path " ${KUBE_ROOT} " /.config\* -o \
119
+ -path " ${KUBE_ROOT} " /.gsutil\* \
120
+ \) -prune \
121
+ \) -print0 \
122
+ | " ${TAR} " czf " ${src_tarball} " --transform " s|${KUBE_ROOT#/* } |kubernetes|" --null -T -
114
123
fi
115
124
}
116
125
117
126
# Package up all of the cross compiled clients. Over time this should grow into
118
127
# a full SDK
119
128
function kube::release::package_client_tarballs() {
120
129
# Find all of the built client binaries
121
- local platform platforms
122
- platforms=($( cd " ${LOCAL_OUTPUT_BINPATH} " ; echo * /* ) )
123
- for platform in " ${platforms[@]} " ; do
124
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
130
+ for platform_long in " ${LOCAL_OUTPUT_BINPATH} " /* /* ; do
131
+ local platform
132
+ local platform_tag
133
+ platform=${platform_long## ${LOCAL_OUTPUT_BINPATH} / } # Strip LOCAL_OUTPUT_BINPATH
134
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
125
135
kube::log::status " Starting tarball: client $platform_tag "
126
136
127
137
(
@@ -130,7 +140,7 @@ function kube::release::package_client_tarballs() {
130
140
mkdir -p " ${release_stage} /client/bin"
131
141
132
142
local client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
133
- if [[ " ${platform%/* } " == " windows" ]]; then
143
+ if [[ " ${platform%/* } " = ' windows' ]]; then
134
144
client_bins=(" ${KUBE_CLIENT_BINARIES_WIN[@]} " )
135
145
fi
136
146
@@ -155,16 +165,18 @@ function kube::release::package_client_tarballs() {
155
165
function kube::release::package_node_tarballs() {
156
166
local platform
157
167
for platform in " ${KUBE_NODE_PLATFORMS[@]} " ; do
158
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
159
- local arch=$( basename " ${platform} " )
168
+ local platform_tag
169
+ local arch
170
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
171
+ arch=$( basename " ${platform} " )
160
172
kube::log::status " Building tarball: node $platform_tag "
161
173
162
174
local release_stage=" ${RELEASE_STAGE} /node/${platform_tag} /kubernetes"
163
175
rm -rf " ${release_stage} "
164
176
mkdir -p " ${release_stage} /node/bin"
165
177
166
178
local node_bins=(" ${KUBE_NODE_BINARIES[@]} " )
167
- if [[ " ${platform%/* } " == " windows" ]]; then
179
+ if [[ " ${platform%/* } " = ' windows' ]]; then
168
180
node_bins=(" ${KUBE_NODE_BINARIES_WIN[@]} " )
169
181
fi
170
182
# This fancy expression will expand to prepend a path
@@ -178,7 +190,7 @@ function kube::release::package_node_tarballs() {
178
190
179
191
# Include the client binaries here too as they are useful debugging tools.
180
192
local client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
181
- if [[ " ${platform%/* } " == " windows" ]]; then
193
+ if [[ " ${platform%/* } " = ' windows' ]]; then
182
194
client_bins=(" ${KUBE_CLIENT_BINARIES_WIN[@]} " )
183
195
fi
184
196
# This fancy expression will expand to prepend a path
@@ -204,11 +216,14 @@ function kube::release::build_server_images() {
204
216
rm -rf " ${RELEASE_IMAGES} "
205
217
local platform
206
218
for platform in " ${KUBE_SERVER_PLATFORMS[@]} " ; do
207
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
208
- local arch=$( basename " ${platform} " )
219
+ local platform_tag
220
+ local arch
221
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
222
+ arch=$( basename " ${platform} " )
209
223
kube::log::status " Building images: $platform_tag "
210
224
211
- local release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
225
+ local release_stage
226
+ release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
212
227
rm -rf " ${release_stage} "
213
228
mkdir -p " ${release_stage} /server/bin"
214
229
@@ -227,12 +242,15 @@ function kube::release::package_server_tarballs() {
227
242
kube::release::build_server_images
228
243
local platform
229
244
for platform in " ${KUBE_SERVER_PLATFORMS[@]} " ; do
230
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
231
- local arch=$( basename " ${platform} " )
245
+ local platform_tag
246
+ local arch
247
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
248
+ arch=$( basename " ${platform} " )
232
249
kube::log::status " Building tarball: server $platform_tag "
233
250
234
251
# NOTE: this directory was setup in kube::release::build_server_images
235
- local release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
252
+ local release_stage
253
+ release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
236
254
mkdir -p " ${release_stage} /addons"
237
255
238
256
# This fancy expression will expand to prepend a path
@@ -242,8 +260,9 @@ function kube::release::package_server_tarballs() {
242
260
" ${release_stage} /server/bin/"
243
261
244
262
# Include the client binaries here too as they are useful debugging tools.
245
- local client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
246
- if [[ " ${platform%/* } " == " windows" ]]; then
263
+ local client_bins
264
+ client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
265
+ if [[ " ${platform%/* } " = ' windows' ]]; then
247
266
client_bins=(" ${KUBE_CLIENT_BINARIES_WIN[@]} " )
248
267
fi
249
268
# This fancy expression will expand to prepend a path
@@ -258,7 +277,8 @@ function kube::release::package_server_tarballs() {
258
277
259
278
kube::release::clean_cruft
260
279
261
- local package_name=" ${RELEASE_TARS} /kubernetes-server-${platform_tag} .tar.gz"
280
+ local package_name
281
+ package_name=" ${RELEASE_TARS} /kubernetes-server-${platform_tag} .tar.gz"
262
282
kube::release::create_tarball " ${package_name} " " ${release_stage} /.."
263
283
done
264
284
}
@@ -288,7 +308,8 @@ function kube::release::build_hyperkube_image() {
288
308
ARCH=" ${arch} " REGISTRY=" ${registry} " VERSION=" ${version} " \
289
309
make -C cluster/images/hyperkube/ build > /dev/null
290
310
291
- local hyperkube_tag=" ${registry} /hyperkube-${arch} :${version} "
311
+ local hyperkube_tag
312
+ hyperkube_tag=" ${registry} /hyperkube-${arch} :${version} "
292
313
if [[ -n " ${save_dir} " ]]; then
293
314
" ${DOCKER[@]} " save " ${hyperkube_tag} " > " ${save_dir} /hyperkube-${arch} .tar"
294
315
fi
@@ -305,7 +326,8 @@ function kube::release::build_conformance_image() {
305
326
ARCH=" ${arch} " REGISTRY=" ${registry} " VERSION=" ${version} " \
306
327
make -C cluster/images/conformance/ build > /dev/null
307
328
308
- local conformance_tag=" ${registry} /conformance-${arch} :${version} "
329
+ local conformance_tag
330
+ conformance_tag=" ${registry} /conformance-${arch} :${version} "
309
331
if [[ -n " ${save_dir} " ]]; then
310
332
" ${DOCKER[@]} " save " ${conformance_tag} " > " ${save_dir} /conformance-${arch} .tar"
311
333
fi
@@ -320,11 +342,14 @@ function kube::release::build_conformance_image() {
320
342
function kube::release::create_docker_images_for_server() {
321
343
# Create a sub-shell so that we don't pollute the outer environment
322
344
(
323
- local binary_dir=" $1 "
324
- local arch=" $2 "
325
- local binary_name
326
- local binaries=($( kube::build::get_docker_wrapped_binaries " ${arch} " ) )
327
- local images_dir=" ${RELEASE_IMAGES} /${arch} "
345
+ local binary_dir
346
+ local arch
347
+ local binaries
348
+ local images_dir
349
+ binary_dir=" $1 "
350
+ arch=" $2 "
351
+ binaries=$( kube::build::get_docker_wrapped_binaries " ${arch} " )
352
+ images_dir=" ${RELEASE_IMAGES} /${arch} "
328
353
mkdir -p " ${images_dir} "
329
354
330
355
# k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE.
@@ -341,31 +366,26 @@ function kube::release::create_docker_images_for_server() {
341
366
# provide `--pull` argument to `docker build` if `KUBE_BUILD_PULL_LATEST_IMAGES`
342
367
# is set to y or Y; otherwise try to build the image without forcefully
343
368
# pulling the latest base image.
344
- local DOCKER_BUILD_OPTS=()
369
+ local docker_build_opts
370
+ docker_build_opts=
345
371
if [[ " ${KUBE_BUILD_PULL_LATEST_IMAGES} " =~ [yY] ]]; then
346
- DOCKER_BUILD_OPTS+=( " --pull" )
372
+ docker_build_opts= ' --pull'
347
373
fi
348
- local -r docker_build_opts=" ${DOCKER_BUILD_OPTS[@]} "
349
374
350
- for wrappable in " ${ binaries[@]} " ; do
375
+ for wrappable in $ binaries; do
351
376
352
- local oldifs=$IFS
353
- IFS=" ,"
354
- set $wrappable
355
- IFS=$oldifs
356
-
357
- local binary_name=" $1 "
358
- local base_image=" $2 "
359
- local docker_build_path=" ${binary_dir} /${binary_name} .dockerbuild"
360
- local docker_file_path=" ${docker_build_path} /Dockerfile"
377
+ local binary_name=${wrappable%% ,* }
378
+ local base_image=${wrappable##* ,}
361
379
local binary_file_path=" ${binary_dir} /${binary_name} "
380
+ local docker_build_path=" ${binary_file_path} .dockerbuild"
381
+ local docker_file_path=" ${docker_build_path} /Dockerfile"
362
382
local docker_image_tag=" ${docker_registry} /${binary_name} -${arch} :${docker_tag} "
363
383
364
384
kube::log::status " Starting docker build for image: ${binary_name} -${arch} "
365
385
(
366
386
rm -rf " ${docker_build_path} "
367
387
mkdir -p " ${docker_build_path} "
368
- ln " ${binary_dir} / ${binary_name }" " ${docker_build_path} /${binary_name} "
388
+ ln " ${binary_file_path } " " ${docker_build_path} /${binary_name} "
369
389
ln " ${KUBE_ROOT} /build/nsswitch.conf" " ${docker_build_path} /nsswitch.conf"
370
390
chmod 0644 " ${docker_build_path} /nsswitch.conf"
371
391
cat << EOF > "${docker_file_path} "
377
397
echo " COPY nsswitch.conf /etc/" >> " ${docker_file_path} "
378
398
fi
379
399
380
- " ${DOCKER[@]} " build ${docker_build_opts} -q -t " ${docker_image_tag} " " ${docker_build_path} " > /dev/null
400
+ " ${DOCKER[@]} " build ${docker_build_opts: + " ${docker_build_opts} " } -q -t " ${docker_image_tag} " " ${docker_build_path} " > /dev/null
381
401
# If we are building an official/alpha/beta release we want to keep
382
402
# docker images and tag them appropriately.
383
403
local -r release_docker_image_tag=" ${KUBE_DOCKER_REGISTRY-$docker_registry } /${binary_name} -${arch} :${KUBE_DOCKER_IMAGE_TAG-$docker_tag } "
@@ -386,10 +406,10 @@ EOF
386
406
" ${DOCKER[@]} " rmi " ${release_docker_image_tag} " 2> /dev/null || true
387
407
" ${DOCKER[@]} " tag " ${docker_image_tag} " " ${release_docker_image_tag} " 2> /dev/null
388
408
fi
389
- " ${DOCKER[@]} " save -o " ${binary_dir} / ${binary_name} .tar" " ${docker_image_tag} " ${release_docker_image_tag}
390
- echo " ${docker_tag} " > " ${binary_dir} / ${binary_name } .docker_tag"
409
+ " ${DOCKER[@]} " save -o " ${binary_file_path} .tar" " ${docker_image_tag} " " ${release_docker_image_tag} "
410
+ echo " ${docker_tag} " > " ${binary_file_path } .docker_tag"
391
411
rm -rf " ${docker_build_path} "
392
- ln " ${binary_dir} / ${binary_name } .tar" " ${images_dir} /"
412
+ ln " ${binary_file_path } .tar" " ${images_dir} /"
393
413
394
414
kube::log::status " Deleting docker image ${docker_image_tag} "
395
415
" ${DOCKER[@]} " rmi " ${docker_image_tag} " & > /dev/null || true
@@ -433,25 +453,17 @@ function kube::release::package_kube_manifests_tarball() {
433
453
cp " ${src_dir} /kube-addon-manager.yaml" " ${dst_dir} "
434
454
cp " ${src_dir} /glbc.manifest" " ${dst_dir} "
435
455
cp " ${src_dir} /etcd-empty-dir-cleanup.yaml" " ${dst_dir} /"
436
- local internal_manifest
437
- for internal_manifest in $( ls " ${src_dir} " | grep " ^internal-*" ) ; do
438
- cp " ${src_dir} /${internal_manifest} " " ${dst_dir} "
439
- done
456
+ find " ${src_dir} " -name ' internal-*' -exec cp {} " ${dst_dir} " \;
440
457
cp " ${KUBE_ROOT} /cluster/gce/gci/configure-helper.sh" " ${dst_dir} /gci-configure-helper.sh"
441
458
cp " ${KUBE_ROOT} /cluster/gce/gci/configure-kubeapiserver.sh" " ${dst_dir} /configure-kubeapiserver.sh"
442
459
if [[ -e " ${KUBE_ROOT} /cluster/gce/gci/gke-internal-configure-helper.sh" ]]; then
443
460
cp " ${KUBE_ROOT} /cluster/gce/gci/gke-internal-configure-helper.sh" " ${dst_dir} /"
444
461
fi
445
462
cp " ${KUBE_ROOT} /cluster/gce/gci/health-monitor.sh" " ${dst_dir} /health-monitor.sh"
446
- local objects
447
- objects=$( cd " ${KUBE_ROOT} /cluster/addons" && find . \( -name \* .yaml -or -name \* .yaml.in -or -name \* .json \) | grep -v demo)
448
- tar c -C " ${KUBE_ROOT} /cluster/addons" ${objects} | tar x -C " ${dst_dir} "
449
463
# Merge GCE-specific addons with general purpose addons.
450
- local gce_objects
451
- gce_objects=$( cd " ${KUBE_ROOT} /cluster/gce/addons" && find . \( -name \* .yaml -or -name \* .yaml.in -or -name \* .json \) \( -not -name \* demo\* \) )
452
- if [[ -n " ${gce_objects} " ]]; then
453
- tar c -C " ${KUBE_ROOT} /cluster/gce/addons" ${gce_objects} | tar x -C " ${dst_dir} "
454
- fi
464
+ for d in cluster/addons cluster/gce/addons; do
465
+ find " ${KUBE_ROOT} /${d} " \( \( -name \* .yaml -o -name \* .yaml.in -o -name \* .json \) -a ! \( -name \* demo\* \) \) -print0 | tar c --transform " s|${KUBE_ROOT#/* } /${d} ||" --null -T - | " ${TAR} " x -C " ${dst_dir} "
466
+ done
455
467
456
468
kube::release::clean_cruft
457
469
@@ -483,7 +495,7 @@ function kube::release::package_test_platform_tarballs() {
483
495
mkdir -p " ${release_stage} /test/bin"
484
496
485
497
local test_bins=(" ${KUBE_TEST_BINARIES[@]} " )
486
- if [[ " ${platform%/* } " == " windows" ]]; then
498
+ if [[ " ${platform%/* } " = ' windows' ]]; then
487
499
test_bins=(" ${KUBE_TEST_BINARIES_WIN[@]} " )
488
500
fi
489
501
# This fancy expression will expand to prepend a path
0 commit comments