Add support to lint the install commands in Dockerfiles
Change-Id: Icb47ba8b13b13889e28bb285321f11344400edc2 Closes-Bug:#1582618
This commit is contained in:
parent
b40bf517ae
commit
eb1bfc2c2e
@ -37,8 +37,8 @@ echo "=== json checks ==="
|
||||
|
||||
${TOPLEVEL}/tools/validate-all-json.sh || RES=1
|
||||
|
||||
echo "=== maintainer checks ==="
|
||||
echo "=== dockerfile checks ==="
|
||||
|
||||
${TOPLEVEL}/tools/validate-all-maintainer.sh || RES=1
|
||||
${TOPLEVEL}/tools/validate-all-dockerfiles || RES=1
|
||||
|
||||
exit $RES
|
||||
|
@ -5,3 +5,7 @@ cd "$(dirname "$REAL_PATH")/.."
|
||||
|
||||
find docker -name Dockerfile.j2 -print0 |
|
||||
xargs -0 tools/validate-maintainer.sh || exit 1
|
||||
|
||||
find docker -name Dockerfile.j2 -print0 |
|
||||
xargs -0 tools/validate-install-command.sh || exit 1
|
||||
|
12
tools/validate-install-command.sh
Executable file
12
tools/validate-install-command.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
RES=0
|
||||
|
||||
for dockerfile in "$@"; do
|
||||
if grep "apt-get install\|yum install" "$dockerfile"; then
|
||||
echo "ERROR: $dockerfile has incorrectly formatted install command Should be in the form 'apt-get|yum -y install ...'" >&2
|
||||
RES=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $RES
|
2
tox.ini
2
tox.ini
@ -23,7 +23,7 @@ commands =
|
||||
flake8 {posargs}
|
||||
{toxinidir}/tools/validate-all-json.sh
|
||||
{toxinidir}/tools/validate-all-yaml.sh
|
||||
{toxinidir}/tools/validate-all-maintainer.sh
|
||||
{toxinidir}/tools/validate-all-dockerfiles.sh
|
||||
|
||||
[testenv:bandit]
|
||||
commands = bandit -r ansible/library dev docker kolla tests tools
|
||||
|
Loading…
Reference in New Issue
Block a user