@@ -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
@@ -100,28 +111,25 @@ function kube::release::package_src_tarball() {
100
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 \
114
+ " ${TAR} " czf " ${src_tarball} " --transform ' s|^\.|kubernetes|' -C " ${KUBE_ROOT} " " $( cd " ${KUBE_ROOT} " && find . -mindepth 1 -maxdepth 1 \
105
115
-not \( \
106
116
\( -path ./_\* -o \
107
117
-path ./.git\* -o \
108
118
-path ./.config\* -o \
109
119
-path ./.gsutil\* \
110
120
\) -prune \
111
- \) )
112
- )
113
- " ${TAR} " czf " ${src_tarball} " --transform ' s|^\.|kubernetes|' -C " ${KUBE_ROOT} " " ${source_files[@]} "
121
+ \) ) "
114
122
fi
115
123
}
116
124
117
125
# Package up all of the cross compiled clients. Over time this should grow into
118
126
# a full SDK
119
127
function kube::release::package_client_tarballs() {
120
128
# 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 "-"
129
+ for platform in " ${LOCAL_OUTPUT_BINPATH} " / * / * ; do
130
+ local platform_tag
131
+ platform_tag= ${platform ## ${LOCAL_OUTPUT_BINPATH} / } # Strip LOCAL_OUTPUT_BINPATH
132
+ platform_tag=${platform_tag / \/ / -} # Replace a "/" for a "-"
125
133
kube::log::status " Starting tarball: client $platform_tag "
126
134
127
135
(
@@ -155,8 +163,10 @@ function kube::release::package_client_tarballs() {
155
163
function kube::release::package_node_tarballs() {
156
164
local platform
157
165
for platform in " ${KUBE_NODE_PLATFORMS[@]} " ; do
158
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
159
- local arch=$( basename " ${platform} " )
166
+ local platform_tag
167
+ local arch
168
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
169
+ arch=$( basename " ${platform} " )
160
170
kube::log::status " Building tarball: node $platform_tag "
161
171
162
172
local release_stage=" ${RELEASE_STAGE} /node/${platform_tag} /kubernetes"
@@ -204,11 +214,14 @@ function kube::release::build_server_images() {
204
214
rm -rf " ${RELEASE_IMAGES} "
205
215
local platform
206
216
for platform in " ${KUBE_SERVER_PLATFORMS[@]} " ; do
207
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
208
- local arch=$( basename " ${platform} " )
217
+ local platform_tag
218
+ local arch
219
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
220
+ arch=$( basename " ${platform} " )
209
221
kube::log::status " Building images: $platform_tag "
210
222
211
- local release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
223
+ local release_stage
224
+ release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
212
225
rm -rf " ${release_stage} "
213
226
mkdir -p " ${release_stage} /server/bin"
214
227
@@ -227,12 +240,15 @@ function kube::release::package_server_tarballs() {
227
240
kube::release::build_server_images
228
241
local platform
229
242
for platform in " ${KUBE_SERVER_PLATFORMS[@]} " ; do
230
- local platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
231
- local arch=$( basename " ${platform} " )
243
+ local platform_tag
244
+ local arch
245
+ platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
246
+ arch=$( basename " ${platform} " )
232
247
kube::log::status " Building tarball: server $platform_tag "
233
248
234
249
# NOTE: this directory was setup in kube::release::build_server_images
235
- local release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
250
+ local release_stage
251
+ release_stage=" ${RELEASE_STAGE} /server/${platform_tag} /kubernetes"
236
252
mkdir -p " ${release_stage} /addons"
237
253
238
254
# This fancy expression will expand to prepend a path
@@ -242,7 +258,8 @@ function kube::release::package_server_tarballs() {
242
258
" ${release_stage} /server/bin/"
243
259
244
260
# Include the client binaries here too as they are useful debugging tools.
245
- local client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
261
+ local client_bins
262
+ client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
246
263
if [[ " ${platform%/* } " == " windows" ]]; then
247
264
client_bins=(" ${KUBE_CLIENT_BINARIES_WIN[@]} " )
248
265
fi
@@ -258,7 +275,8 @@ function kube::release::package_server_tarballs() {
258
275
259
276
kube::release::clean_cruft
260
277
261
- local package_name=" ${RELEASE_TARS} /kubernetes-server-${platform_tag} .tar.gz"
278
+ local package_name
279
+ package_name=" ${RELEASE_TARS} /kubernetes-server-${platform_tag} .tar.gz"
262
280
kube::release::create_tarball " ${package_name} " " ${release_stage} /.."
263
281
done
264
282
}
@@ -288,7 +306,8 @@ function kube::release::build_hyperkube_image() {
288
306
ARCH=" ${arch} " REGISTRY=" ${registry} " VERSION=" ${version} " \
289
307
make -C cluster/images/hyperkube/ build > /dev/null
290
308
291
- local hyperkube_tag=" ${registry} /hyperkube-${arch} :${version} "
309
+ local hyperkube_tag
310
+ hyperkube_tag=" ${registry} /hyperkube-${arch} :${version} "
292
311
if [[ -n " ${save_dir} " ]]; then
293
312
" ${DOCKER[@]} " save " ${hyperkube_tag} " > " ${save_dir} /hyperkube-${arch} .tar"
294
313
fi
@@ -305,7 +324,8 @@ function kube::release::build_conformance_image() {
305
324
ARCH=" ${arch} " REGISTRY=" ${registry} " VERSION=" ${version} " \
306
325
make -C cluster/images/conformance/ build > /dev/null
307
326
308
- local conformance_tag=" ${registry} /conformance-${arch} :${version} "
327
+ local conformance_tag
328
+ conformance_tag=" ${registry} /conformance-${arch} :${version} "
309
329
if [[ -n " ${save_dir} " ]]; then
310
330
" ${DOCKER[@]} " save " ${conformance_tag} " > " ${save_dir} /conformance-${arch} .tar"
311
331
fi
@@ -320,11 +340,15 @@ function kube::release::build_conformance_image() {
320
340
function kube::release::create_docker_images_for_server() {
321
341
# Create a sub-shell so that we don't pollute the outer environment
322
342
(
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} "
343
+ local binary_dir
344
+ local arch
345
+ local binaries
346
+ local images_dir
347
+ binary_dir=" $1 "
348
+ arch=" $2 "
349
+ binary_name
350
+ binaries=$( kube::build::get_docker_wrapped_binaries " ${arch} " )
351
+ images_dir=" ${RELEASE_IMAGES} /${arch} "
328
352
mkdir -p " ${images_dir} "
329
353
330
354
# k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE.
@@ -341,31 +365,31 @@ function kube::release::create_docker_images_for_server() {
341
365
# provide `--pull` argument to `docker build` if `KUBE_BUILD_PULL_LATEST_IMAGES`
342
366
# is set to y or Y; otherwise try to build the image without forcefully
343
367
# pulling the latest base image.
344
- local DOCKER_BUILD_OPTS=()
368
+ local docker_build_opts
369
+ docker_build_opts=
345
370
if [[ " ${KUBE_BUILD_PULL_LATEST_IMAGES} " =~ [yY] ]]; then
346
- DOCKER_BUILD_OPTS+=( " --pull" )
371
+ docker_build_opts= ' --pull'
347
372
fi
348
- local -r docker_build_opts=" ${DOCKER_BUILD_OPTS[@]} "
349
373
350
374
for wrappable in " ${binaries[@]} " ; do
351
375
352
376
local oldifs=$IFS
353
377
IFS=" ,"
354
- set $wrappable
378
+ set " $wrappable "
355
379
IFS=$oldifs
356
380
357
381
local binary_name=" $1 "
358
382
local base_image=" $2 "
359
- local docker_build_path=" ${binary_dir} /${binary_name} .dockerbuild"
360
- local docker_file_path=" ${docker_build_path} /Dockerfile"
361
383
local binary_file_path=" ${binary_dir} /${binary_name} "
384
+ local docker_build_path=" ${binary_file_path} .dockerbuild"
385
+ local docker_file_path=" ${docker_build_path} /Dockerfile"
362
386
local docker_image_tag=" ${docker_registry} /${binary_name} -${arch} :${docker_tag} "
363
387
364
388
kube::log::status " Starting docker build for image: ${binary_name} -${arch} "
365
389
(
366
390
rm -rf " ${docker_build_path} "
367
391
mkdir -p " ${docker_build_path} "
368
- ln " ${binary_dir} / ${binary_name }" " ${docker_build_path} /${binary_name} "
392
+ ln " ${binary_file_path } " " ${docker_build_path} /${binary_name} "
369
393
ln " ${KUBE_ROOT} /build/nsswitch.conf" " ${docker_build_path} /nsswitch.conf"
370
394
chmod 0644 " ${docker_build_path} /nsswitch.conf"
371
395
cat << EOF > "${docker_file_path} "
377
401
echo " COPY nsswitch.conf /etc/" >> " ${docker_file_path} "
378
402
fi
379
403
380
- " ${DOCKER[@]} " build ${docker_build_opts} -q -t " ${docker_image_tag} " " ${docker_build_path} " > /dev/null
404
+ " ${DOCKER[@]} " build " ${docker_build_opts} " -q -t " ${docker_image_tag} " " ${docker_build_path} " > /dev/null
381
405
# If we are building an official/alpha/beta release we want to keep
382
406
# docker images and tag them appropriately.
383
407
local -r release_docker_image_tag=" ${KUBE_DOCKER_REGISTRY-$docker_registry } /${binary_name} -${arch} :${KUBE_DOCKER_IMAGE_TAG-$docker_tag } "
@@ -386,10 +410,10 @@ EOF
386
410
" ${DOCKER[@]} " rmi " ${release_docker_image_tag} " 2> /dev/null || true
387
411
" ${DOCKER[@]} " tag " ${docker_image_tag} " " ${release_docker_image_tag} " 2> /dev/null
388
412
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"
413
+ " ${DOCKER[@]} " save -o " ${binary_file_path} .tar" " ${docker_image_tag} " " ${release_docker_image_tag} "
414
+ echo " ${docker_tag} " > " ${binary_file_path } .docker_tag"
391
415
rm -rf " ${docker_build_path} "
392
- ln " ${binary_dir} / ${binary_name } .tar" " ${images_dir} /"
416
+ ln " ${binary_file_path } .tar" " ${images_dir} /"
393
417
394
418
kube::log::status " Deleting docker image ${docker_image_tag} "
395
419
" ${DOCKER[@]} " rmi " ${docker_image_tag} " & > /dev/null || true
@@ -434,8 +458,8 @@ function kube::release::package_kube_manifests_tarball() {
434
458
cp " ${src_dir} /glbc.manifest" " ${dst_dir} "
435
459
cp " ${src_dir} /etcd-empty-dir-cleanup.yaml" " ${dst_dir} /"
436
460
local internal_manifest
437
- for internal_manifest in $( ls " ${src_dir} " | grep " ^ internal-* " ) ; do
438
- cp " ${src_dir} / ${ internal_manifest}" " ${dst_dir} "
461
+ for internal_manifest in " ${src_dir} / internal-" * ; do
462
+ cp " ${internal_manifest} " " ${dst_dir} "
439
463
done
440
464
cp " ${KUBE_ROOT} /cluster/gce/gci/configure-helper.sh" " ${dst_dir} /gci-configure-helper.sh"
441
465
cp " ${KUBE_ROOT} /cluster/gce/gci/configure-kubeapiserver.sh" " ${dst_dir} /configure-kubeapiserver.sh"
@@ -445,12 +469,12 @@ function kube::release::package_kube_manifests_tarball() {
445
469
cp " ${KUBE_ROOT} /cluster/gce/gci/health-monitor.sh" " ${dst_dir} /health-monitor.sh"
446
470
local objects
447
471
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} "
472
+ tar c -C " ${KUBE_ROOT} /cluster/addons" " ${objects} " | tar x -C " ${dst_dir} "
449
473
# Merge GCE-specific addons with general purpose addons.
450
474
local gce_objects
451
475
gce_objects=$( cd " ${KUBE_ROOT} /cluster/gce/addons" && find . \( -name \* .yaml -or -name \* .yaml.in -or -name \* .json \) \( -not -name \* demo\* \) )
452
476
if [[ -n " ${gce_objects} " ]]; then
453
- tar c -C " ${KUBE_ROOT} /cluster/gce/addons" ${gce_objects} | tar x -C " ${dst_dir} "
477
+ tar c -C " ${KUBE_ROOT} /cluster/gce/addons" " ${gce_objects} " | tar x -C " ${dst_dir} "
454
478
fi
455
479
456
480
kube::release::clean_cruft
0 commit comments