Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hadolint
28 changes: 22 additions & 6 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,28 @@ set -o nounset

export PATH=$PATH:/usr/local/bin

if ! which hadolint &>/dev/null; then
>&2 echo 'hadolint command not found'
if [ -z "$(command -v brew)" ]; then
exit 1
CMD="hadolint"
SCRIPT_DIR="$( cd `dirname "$0"` && pwd )"
export PATH="$SCRIPT_DIR:$PATH"

if ! command -v hadolint >/dev/null; then
if [ -n "$(command -v brew)" ]; then
>&2 echo "hadolint: installing using brew"
brew install hadolint
elif [ -n "$(command -v curl)" ]; then
VERSION="v1.17.6"
URL="https://github.com/hadolint/hadolint/releases/download/$VERSION/hadolint-$(uname)-x86_64"
if ! curl -fsSL "$URL" -o "$SCRIPT_DIR/hadolint"; then
>&2 echo "hadolint: unable to download from $URL"
exit 1
fi
chmod +x "$SCRIPT_DIR/hadolint"
elif [ -n "$(command -v docker)" ]; then
>&2 echo "hadolint: running with docker"
CMD="docker run --rm --volume=$PWD:$PWD:ro --workdir=$PWD hadolint/hadolint hadolint"
else
>&2 echo "hadolint: command not found and don't know how to install"
fi
brew install hadolint
fi

hadolint "$@"
$CMD "$@"