Skip to content

Commit

Permalink
Add support to lint the install commands in Dockerfiles
Browse files Browse the repository at this point in the history
Change-Id: Icb47ba8b13b13889e28bb285321f11344400edc2
Closes-Bug:#1582618
  • Loading branch information
Swapnil Kulkarni (coolsvap) committed May 26, 2016
1 parent b40bf51 commit eb1bfc2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/pre-commit-hook
Expand Up @@ -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
Expand Up @@ -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 changes: 12 additions & 0 deletions tools/validate-install-command.sh
@@ -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 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -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
Expand Down

0 comments on commit eb1bfc2

Please sign in to comment.