Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
34425974
Unverified
Commit
34425974
authored
Jan 29, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73117 from war-turtle/fixShellCheck
Fixes shellcheck warning in build/common.sh
parents
7f82a231
b1b7d0db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
23 deletions
+18
-23
common.sh
build/common.sh
+18
-22
.shellcheck_failures
hack/.shellcheck_failures
+0
-1
No files found.
build/common.sh
View file @
34425974
...
@@ -26,13 +26,13 @@ USER_ID=$(id -u)
...
@@ -26,13 +26,13 @@ USER_ID=$(id -u)
GROUP_ID
=
$(
id
-g
)
GROUP_ID
=
$(
id
-g
)
DOCKER_OPTS
=
${
DOCKER_OPTS
:-
""
}
DOCKER_OPTS
=
${
DOCKER_OPTS
:-
""
}
DOCKER
=(
docker
${
DOCKER_OPTS
}
)
IFS
=
" "
read
-r
-a
DOCKER
<<<
"docker
${
DOCKER_OPTS
}
"
DOCKER_HOST
=
${
DOCKER_HOST
:-
""
}
DOCKER_HOST
=
${
DOCKER_HOST
:-
""
}
DOCKER_MACHINE_NAME
=
${
DOCKER_MACHINE_NAME
:-
"kube-dev"
}
DOCKER_MACHINE_NAME
=
${
DOCKER_MACHINE_NAME
:-
"kube-dev"
}
readonly
DOCKER_MACHINE_DRIVER
=
${
DOCKER_MACHINE_DRIVER
:-
"virtualbox --virtualbox-cpu-count -1"
}
readonly
DOCKER_MACHINE_DRIVER
=
${
DOCKER_MACHINE_DRIVER
:-
"virtualbox --virtualbox-cpu-count -1"
}
# This will canonicalize the path
# This will canonicalize the path
KUBE_ROOT
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
}
"
)
"
/..
&&
pwd
-P
)
KUBE_ROOT
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
/..
&&
pwd
-P
)
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
...
@@ -137,7 +137,7 @@ function kube::build::verify_prereqs() {
...
@@ -137,7 +137,7 @@ function kube::build::verify_prereqs() {
fi
fi
kube::util::ensure_docker_daemon_connectivity
||
return
1
kube::util::ensure_docker_daemon_connectivity
||
return
1
if
((
${
KUBE_VERBOSE
}
>
6
))
;
then
if
((
KUBE_VERBOSE
>
6
))
;
then
kube::log::status
"Docker Version:"
kube::log::status
"Docker Version:"
"
${
DOCKER
[@]
}
"
version | kube::log::info_from_stdin
"
${
DOCKER
[@]
}
"
version | kube::log::info_from_stdin
fi
fi
...
@@ -185,7 +185,8 @@ function kube::build::docker_available_on_osx() {
...
@@ -185,7 +185,8 @@ function kube::build::docker_available_on_osx() {
function
kube::build::prepare_docker_machine
()
{
function
kube::build::prepare_docker_machine
()
{
kube::log::status
"docker-machine was found."
kube::log::status
"docker-machine was found."
local
available_memory_bytes
=
$(
sysctl
-n
hw.memsize 2>/dev/null
)
local
available_memory_bytes
available_memory_bytes
=
$(
sysctl
-n
hw.memsize 2>/dev/null
)
local
bytes_in_mb
=
1048576
local
bytes_in_mb
=
1048576
...
@@ -193,7 +194,7 @@ function kube::build::prepare_docker_machine() {
...
@@ -193,7 +194,7 @@ function kube::build::prepare_docker_machine() {
# of multiple by .5, because bash can only multiply by ints.
# of multiple by .5, because bash can only multiply by ints.
local
memory_divisor
=
2
local
memory_divisor
=
2
local
virtualbox_memory_mb
=
$((
${
available_memory_bytes
}
/
(
${
bytes_in_mb
}
*
${
memory_divisor
}
)
))
local
virtualbox_memory_mb
=
$((
available_memory_bytes
/
(
bytes_in_mb
*
memory_divisor
)
))
docker-machine inspect
"
${
DOCKER_MACHINE_NAME
}
"
&> /dev/null
||
{
docker-machine inspect
"
${
DOCKER_MACHINE_NAME
}
"
&> /dev/null
||
{
kube::log::status
"Creating a machine to build Kubernetes"
kube::log::status
"Creating a machine to build Kubernetes"
...
@@ -215,7 +216,7 @@ function kube::build::prepare_docker_machine() {
...
@@ -215,7 +216,7 @@ function kube::build::prepare_docker_machine() {
while
!
docker_machine_out
=
$(
docker-machine
env
"
${
DOCKER_MACHINE_NAME
}
"
2>&1
)
;
do
while
!
docker_machine_out
=
$(
docker-machine
env
"
${
DOCKER_MACHINE_NAME
}
"
2>&1
)
;
do
if
[[
${
docker_machine_out
}
=
~
"Error checking TLS connection"
]]
;
then
if
[[
${
docker_machine_out
}
=
~
"Error checking TLS connection"
]]
;
then
echo
"
${
docker_machine_out
}
"
echo
"
${
docker_machine_out
}
"
docker-machine regenerate-certs
${
DOCKER_MACHINE_NAME
}
docker-machine regenerate-certs
"
${
DOCKER_MACHINE_NAME
}
"
else
else
sleep
1
sleep
1
fi
fi
...
@@ -368,7 +369,7 @@ function kube::build::short_hash() {
...
@@ -368,7 +369,7 @@ function kube::build::short_hash() {
else
else
short_hash
=
$(
echo
-n
"
$1
"
|
md5sum
)
short_hash
=
$(
echo
-n
"
$1
"
|
md5sum
)
fi
fi
echo
${
short_hash
:0:10
}
echo
"
${
short_hash
:0:10
}
"
}
}
# Pedantically kill, wait-on and remove a container. The -f -v options
# Pedantically kill, wait-on and remove a container. The -f -v options
...
@@ -412,7 +413,7 @@ function kube::build::clean() {
...
@@ -412,7 +413,7 @@ function kube::build::clean() {
function
kube::build::build_image
()
{
function
kube::build::build_image
()
{
mkdir
-p
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
"
mkdir
-p
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
"
# Make sure the context directory owned by the right user for syncing sources to container.
# Make sure the context directory owned by the right user for syncing sources to container.
chown
-R
${
USER_ID
}
:
${
GROUP_ID
}
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
"
chown
-R
"
${
USER_ID
}
"
:
"
${
GROUP_ID
}
"
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
"
cp
/etc/localtime
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/"
cp
/etc/localtime
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/"
...
@@ -503,7 +504,7 @@ function kube::build::ensure_data_container() {
...
@@ -503,7 +504,7 @@ function kube::build::ensure_data_container() {
--name
"
${
KUBE_DATA_CONTAINER_NAME
}
"
--name
"
${
KUBE_DATA_CONTAINER_NAME
}
"
--hostname
"
${
HOSTNAME
}
"
--hostname
"
${
HOSTNAME
}
"
"
${
KUBE_BUILD_IMAGE
}
"
"
${
KUBE_BUILD_IMAGE
}
"
chown
-R
${
USER_ID
}
:
${
GROUP_ID
}
chown
-R
"
${
USER_ID
}
"
:
"
${
GROUP_ID
}
"
"
${
REMOTE_ROOT
}
"
"
${
REMOTE_ROOT
}
"
/usr/local/go/pkg/
/usr/local/go/pkg/
)
)
...
@@ -582,7 +583,7 @@ function kube::build::run_build_command_ex() {
...
@@ -582,7 +583,7 @@ function kube::build::run_build_command_ex() {
if
[[
-t
0
]]
;
then
if
[[
-t
0
]]
;
then
docker_run_opts+
=(
--interactive
--tty
)
docker_run_opts+
=(
--interactive
--tty
)
elif
[[
"
${
detach
}
"
==
false
]]
;
then
elif
[[
"
${
detach
}
"
==
false
]]
;
then
docker_run_opts+
=(
--attach
=
stdout
--attach
=
stderr
)
docker_run_opts+
=(
"--attach=stdout"
"--attach=stderr"
)
fi
fi
local
-ra
docker_cmd
=(
local
-ra
docker_cmd
=(
...
@@ -599,13 +600,13 @@ function kube::build::run_build_command_ex() {
...
@@ -599,13 +600,13 @@ function kube::build::run_build_command_ex() {
function
kube::build::rsync_probe
{
function
kube::build::rsync_probe
{
# Wait unil rsync is up and running.
# Wait unil rsync is up and running.
local
tries
=
20
local
tries
=
20
while
((
${
tries
}
>
0
))
;
do
while
((
tries
>
0
))
;
do
if
rsync
"rsync://k8s@
${
1
}
:
${
2
}
/"
\
if
rsync
"rsync://k8s@
${
1
}
:
${
2
}
/"
\
--password-file
=
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/rsyncd.password"
\
--password-file
=
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/rsyncd.password"
\
&> /dev/null
;
then
&> /dev/null
;
then
return
0
return
0
fi
fi
tries
=
$((
${
tries
}
-
1
))
tries
=
$((
tries
-
1
))
sleep
0.1
sleep
0.1
done
done
...
@@ -625,7 +626,7 @@ function kube::build::start_rsyncd_container() {
...
@@ -625,7 +626,7 @@ function kube::build::start_rsyncd_container() {
kube::build::stop_rsyncd_container
kube::build::stop_rsyncd_container
V
=
3 kube::log::status
"Starting rsyncd container"
V
=
3 kube::log::status
"Starting rsyncd container"
kube::build::run_build_command_ex
\
kube::build::run_build_command_ex
\
"
${
KUBE_RSYNC_CONTAINER_NAME
}
"
-p
127.0.0.1:
${
KUBE_RSYNC_PORT
}
:
${
KUBE_CONTAINER_RSYNC_PORT
}
-d
\
"
${
KUBE_RSYNC_CONTAINER_NAME
}
"
-p
127.0.0.1:
"
${
KUBE_RSYNC_PORT
}
"
:
"
${
KUBE_CONTAINER_RSYNC_PORT
}
"
-d
\
-e
ALLOW_HOST
=
"
$(${
IPTOOL
}
|
grep
-Eo
'inet (addr:)?([0-9]*\.){3}[0-9]*'
|
grep
-Eo
'([0-9]*\.){3}[0-9]*'
|
grep
-v
'127.0.0.1'
)
"
\
-e
ALLOW_HOST
=
"
$(${
IPTOOL
}
|
grep
-Eo
'inet (addr:)?([0-9]*\.){3}[0-9]*'
|
grep
-Eo
'([0-9]*\.){3}[0-9]*'
|
grep
-v
'127.0.0.1'
)
"
\
--
/rsyncd.sh
>
/dev/null
--
/rsyncd.sh
>
/dev/null
...
@@ -643,7 +644,7 @@ function kube::build::start_rsyncd_container() {
...
@@ -643,7 +644,7 @@ function kube::build::start_rsyncd_container() {
# machines) we have to talk directly to the container IP. There is no one
# machines) we have to talk directly to the container IP. There is no one
# strategy that works in all cases so we test to figure out which situation we
# strategy that works in all cases so we test to figure out which situation we
# are in.
# are in.
if
kube::build::rsync_probe 127.0.0.1
${
mapped_port
}
;
then
if
kube::build::rsync_probe 127.0.0.1
"
${
mapped_port
}
"
;
then
KUBE_RSYNC_ADDR
=
"127.0.0.1:
${
mapped_port
}
"
KUBE_RSYNC_ADDR
=
"127.0.0.1:
${
mapped_port
}
"
return
0
return
0
elif
kube::build::rsync_probe
"
${
container_ip
}
"
${
KUBE_CONTAINER_RSYNC_PORT
}
;
then
elif
kube::build::rsync_probe
"
${
container_ip
}
"
${
KUBE_CONTAINER_RSYNC_PORT
}
;
then
...
@@ -664,12 +665,12 @@ function kube::build::stop_rsyncd_container() {
...
@@ -664,12 +665,12 @@ function kube::build::stop_rsyncd_container() {
function
kube::build::rsync
{
function
kube::build::rsync
{
local
-a
rsync_opts
=(
local
-a
rsync_opts
=(
--archive
--archive
--password-file
=
"
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/rsyncd.password"
"--password-file=
${
LOCAL_OUTPUT_BUILD_CONTEXT
}
/rsyncd.password"
)
)
if
((
${
KUBE_VERBOSE
}
>=
6
))
;
then
if
((
KUBE_VERBOSE
>=
6
))
;
then
rsync_opts+
=(
"-iv"
)
rsync_opts+
=(
"-iv"
)
fi
fi
if
((
${
KUBE_RSYNC_COMPRESS
}
>
0
))
;
then
if
((
KUBE_RSYNC_COMPRESS
>
0
))
;
then
rsync_opts+
=(
"--compress-level=
${
KUBE_RSYNC_COMPRESS
}
"
)
rsync_opts+
=(
"--compress-level=
${
KUBE_RSYNC_COMPRESS
}
"
)
fi
fi
V
=
3 kube::log::status
"Running rsync"
V
=
3 kube::log::status
"Running rsync"
...
@@ -712,11 +713,6 @@ function kube::build::copy_output() {
...
@@ -712,11 +713,6 @@ function kube::build::copy_output() {
kube::build::start_rsyncd_container
kube::build::start_rsyncd_container
local
rsync_extra
=
""
if
((
${
KUBE_VERBOSE
}
>=
6
))
;
then
rsync_extra
=
"-iv"
fi
# The filter syntax for rsync is a little obscure. It filters on files and
# The filter syntax for rsync is a little obscure. It filters on files and
# directories. If you don't go in to a directory you won't find any files
# directories. If you don't go in to a directory you won't find any files
# there. Rules are evaluated in order. The last two rules are a little
# there. Rules are evaluated in order. The last two rules are a little
...
...
hack/.shellcheck_failures
View file @
34425974
./build/common.sh
./build/lib/release.sh
./build/lib/release.sh
./cluster/addons/addon-manager/kube-addons.sh
./cluster/addons/addon-manager/kube-addons.sh
./cluster/addons/fluentd-elasticsearch/es-image/run.sh
./cluster/addons/fluentd-elasticsearch/es-image/run.sh
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment