Skip to content

Commit f22bf4f

Browse files
authored
Merge pull request canonical#2287 from stgraber/master
Bugfixes
2 parents 799e2a1 + bf70193 commit f22bf4f

File tree

10 files changed

+44
-9
lines changed

10 files changed

+44
-9
lines changed

lxd-bridge/lxd-bridge

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ LXD_IPV6_NETWORK=""
2727
LXD_IPV6_NAT="false"
2828
LXD_IPV6_PROXY="true"
2929

30+
# shellcheck disable=SC1090
3031
[ ! -f "${config}" ] || . "${config}"
3132

3233
use_iptables_lock="-w"
@@ -39,7 +40,7 @@ HAS_IPV6=false
3940
_netmask2cidr ()
4041
{
4142
# Assumes there's no "255." after a non-255 byte in the mask
42-
local x=${1##*255.}
43+
x=${1##*255.}
4344
set -- "0^^^128^192^224^240^248^252^254^" "$(( (${#1} - ${#x})*2 ))" "${x%%.*}"
4445
x=${1%%${3}*}
4546
echo $(( ${2} + (${#x}/4) ))
@@ -164,7 +165,7 @@ start() {
164165

165166
if [ -n "${LXD_IPV4_ADDR}" ] || [ -n "${LXD_IPV6_ADDR}" ]; then
166167
# shellcheck disable=SC2086
167-
dnsmasq ${LXD_CONFILE_ARG} ${LXD_DOMAIN_ARG} -u "${DNSMASQ_USER}" --strict-order --bind-interfaces --pid-file="${varrun}/dnsmasq.pid" --dhcp-no-override --except-interface=lo --interface="${LXD_BRIDGE}" --dhcp-leasefile="${varlib}/dnsmasq.${LXD_BRIDGE}.leases" --dhcp-authoritative ${LXD_IPV4_ARG} ${LXD_IPV6_ARG} || cleanup
168+
dnsmasq ${LXD_CONFILE_ARG} ${LXD_DOMAIN_ARG} -u "${DNSMASQ_USER}" --strict-order --bind-interfaces --pid-file="${varrun}/dnsmasq.pid" --dhcp-no-override --except-interface=lo --interface="${LXD_BRIDGE}" --dhcp-leasefile="${varlib}/dnsmasq.${LXD_BRIDGE}.leases" --dhcp-authoritative ${LXD_IPV4_ARG} ${LXD_IPV6_ARG}
168169
fi
169170

170171
if [ "${HAS_IPV6}" = "true" ] && [ "${LXD_IPV6_PROXY}" = "true" ]; then

test/backends/btrfs.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

33
btrfs_setup() {
4+
# shellcheck disable=2039
45
local LXD_DIR
6+
57
LXD_DIR=$1
68

79
echo "==> Setting up btrfs backend in ${LXD_DIR}"
@@ -17,14 +19,18 @@ btrfs_setup() {
1719
}
1820

1921
btrfs_configure() {
22+
# shellcheck disable=2039
2023
local LXD_DIR
24+
2125
LXD_DIR=$1
2226

2327
echo "==> Configuring btrfs backend in ${LXD_DIR}"
2428
}
2529

2630
btrfs_teardown() {
31+
# shellcheck disable=2039
2732
local LXD_DIR
33+
2834
LXD_DIR=$1
2935

3036
echo "==> Tearing down btrfs backend in ${LXD_DIR}"

test/backends/dir.sh

+6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55

66
# Any necessary backend-specific setup
77
dir_setup() {
8+
# shellcheck disable=2039
89
local LXD_DIR
10+
911
LXD_DIR=$1
1012

1113
echo "==> Setting up directory backend in ${LXD_DIR}"
1214
}
1315

1416
# Do the API voodoo necessary to configure LXD to use this backend
1517
dir_configure() {
18+
# shellcheck disable=2039
1619
local LXD_DIR
20+
1721
LXD_DIR=$1
1822

1923
echo "==> Configuring directory backend in ${LXD_DIR}"
2024
}
2125

2226
dir_teardown() {
27+
# shellcheck disable=2039
2328
local LXD_DIR
29+
2430
LXD_DIR=$1
2531

2632
echo "==> Tearing down directory backend in ${LXD_DIR}"

test/backends/lvm.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

33
lvm_setup() {
4+
# shellcheck disable=2039
45
local LXD_DIR
6+
57
LXD_DIR=$1
68

79
echo "==> Setting up lvm backend in ${LXD_DIR}"
@@ -23,7 +25,9 @@ lvm_setup() {
2325
}
2426

2527
lvm_configure() {
28+
# shellcheck disable=2039
2629
local LXD_DIR
30+
2731
LXD_DIR=$1
2832

2933
echo "==> Configuring lvm backend in ${LXD_DIR}"
@@ -33,7 +37,9 @@ lvm_configure() {
3337
}
3438

3539
lvm_teardown() {
40+
# shellcheck disable=2039
3641
local LXD_DIR
42+
3743
LXD_DIR=$1
3844

3945
echo "==> Tearing down lvm backend in ${LXD_DIR}"

test/backends/zfs.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
22

33
zfs_setup() {
4+
# shellcheck disable=2039
45
local LXD_DIR
6+
57
LXD_DIR=$1
68

79
echo "==> Setting up ZFS backend in ${LXD_DIR}"
@@ -17,7 +19,9 @@ zfs_setup() {
1719
}
1820

1921
zfs_configure() {
22+
# shellcheck disable=2039
2023
local LXD_DIR
24+
2125
LXD_DIR=$1
2226

2327
echo "==> Configuring ZFS backend in ${LXD_DIR}"
@@ -26,7 +30,9 @@ zfs_configure() {
2630
}
2731

2832
zfs_teardown() {
33+
# shellcheck disable=2039
2934
local LXD_DIR
35+
3036
LXD_DIR=$1
3137

3238
echo "==> Tearing down ZFS backend in ${LXD_DIR}"

test/main.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local_tcp_port() {
3939

4040
# import all the backends
4141
for backend in backends/*.sh; do
42+
# shellcheck disable=SC1090
4243
. "${backend}"
4344
done
4445

@@ -50,6 +51,8 @@ spawn_lxd() {
5051
set +x
5152
# LXD_DIR is local here because since $(lxc) is actually a function, it
5253
# overwrites the environment and we would lose LXD_DIR's value otherwise.
54+
55+
# shellcheck disable=2039
5356
local LXD_DIR
5457

5558
lxddir=${1}
@@ -192,7 +195,10 @@ check_empty_table() {
192195
kill_lxd() {
193196
# LXD_DIR is local here because since $(lxc) is actually a function, it
194197
# overwrites the environment and we would lose LXD_DIR's value otherwise.
198+
199+
# shellcheck disable=2039
195200
local LXD_DIR
201+
196202
daemon_dir=${1}
197203
LXD_DIR=${daemon_dir}
198204
daemon_pid=$(cat "${daemon_dir}/lxd.pid")
@@ -279,13 +285,13 @@ cleanup() {
279285
echo "Tests Completed (${TEST_RESULT}): hit enter to continue"
280286

281287
# shellcheck disable=SC2034
282-
read nothing
288+
read -r nothing
283289
fi
284290

285291
echo "==> Cleaning up"
286292

287293
# Kill all the LXD instances
288-
while read daemon_dir; do
294+
while read -r daemon_dir; do
289295
kill_lxd "${daemon_dir}"
290296
done < "${TEST_DIR}/daemons"
291297

@@ -309,12 +315,12 @@ wipe() {
309315
fi
310316

311317
# shellcheck disable=SC2009
312-
ps aux | grep lxc-monitord | grep "${1}" | awk '{print $2}' | while read pid; do
318+
ps aux | grep lxc-monitord | grep "${1}" | awk '{print $2}' | while read -r pid; do
313319
kill -9 "${pid}"
314320
done
315321

316322
if [ -f "${TEST_DIR}/loops" ]; then
317-
while read line; do
323+
while read -r line; do
318324
losetup -d "${line}" || true
319325
done < "${TEST_DIR}/loops"
320326
fi
@@ -333,6 +339,7 @@ trap cleanup EXIT HUP INT TERM
333339

334340
# Import all the testsuites
335341
for suite in suites/*.sh; do
342+
# shellcheck disable=SC1090
336343
. "${suite}"
337344
done
338345

test/suites/basic.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test_basic_usage() {
88
sum=$(lxc image info testimage | grep ^Fingerprint | cut -d' ' -f2)
99
lxc image export testimage "${LXD_DIR}/"
1010
[ "${sum}" = "$(sha256sum "${LXD_DIR}/${sum}.tar.xz" | cut -d' ' -f1)" ]
11-
11+
1212
# Test an alias with slashes
1313
lxc image show "${sum}"
1414
lxc image alias create a/b/ "${sum}"
@@ -202,6 +202,7 @@ test_basic_usage() {
202202
# Test "nonetype" container creation with an LXC config
203203
wait_for "${LXD_ADDR}" my_curl -X POST "https://${LXD_ADDR}/1.0/containers" \
204204
-d "{\"name\":\"configtest\",\"config\":{\"raw.lxc\":\"lxc.hook.clone=/bin/true\"},\"source\":{\"type\":\"none\"}}"
205+
# shellcheck disable=SC2102
205206
[ "$(my_curl "https://${LXD_ADDR}/1.0/containers/configtest" | jq -r .metadata.config[\"raw.lxc\"])" = "lxc.hook.clone=/bin/true" ]
206207
lxc delete configtest
207208

test/suites/devlxd.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
test_devlxd() {
44
ensure_import_testimage
55

6+
# shellcheck disable=SC2164
67
cd "${TEST_DIR}"
78
go build -tags netgo -a -installsuffix devlxd ../deps/devlxd-client.go
9+
# shellcheck disable=SC2164
810
cd -
911

1012
lxc launch testimage devlxd

test/suites/remote.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test_remote_url() {
44
for url in "${LXD_ADDR}" "https://${LXD_ADDR}"; do
55
lxc_remote remote add test "${url}" --accept-certificate --password foo
66
lxc_remote finger test:
7-
lxc_remote config trust list | grep @ | awk '{print $2}' | while read line ; do
7+
lxc_remote config trust list | grep @ | awk '{print $2}' | while read -r line ; do
88
lxc_remote config trust remove "\"${line}\""
99
done
1010
lxc_remote remote remove test

test/suites/static_analysis.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
safe_pot_hash() {
4-
sed -e "/Project-Id-Version/,/Content-Transfer-Encoding/d" -e "/^#/d" "po/lxd.pot" | tee /tmp/foo | md5sum | cut -f1 -d" "
4+
sed -e "/Project-Id-Version/,/Content-Transfer-Encoding/d" -e "/^#/d" "po/lxd.pot" | md5sum | cut -f1 -d" "
55
}
66

77
test_static_analysis() {

0 commit comments

Comments
 (0)