From 7c8482c72b6458869b680bf052109934cbda86e6 Mon Sep 17 00:00:00 2001 From: Lucian Poston Date: Mon, 17 Feb 2020 19:18:15 -0600 Subject: [PATCH 1/2] Add bash to Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 32e0831..f0d0831 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM python:3-alpine RUN pip install yamllint && \ + apk add bash && \ rm -rf ~/.cache/pip ADD entrypoint.sh /entrypoint.sh From 4d720f5e9047a245d354343f8415c68c0faf428d Mon Sep 17 00:00:00 2001 From: Lucian Poston Date: Mon, 17 Feb 2020 20:02:36 -0600 Subject: [PATCH 2/2] Rewrite entrypoint in bash Fixes #2 Fixes #3 --- entrypoint.sh | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b24f9b5..f3fbfc7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,23 +1,27 @@ -#!/bin/sh -l +#!/bin/bash -l echo "======================" echo "= Linting YAML files =" echo "======================" +if [[ -n "$INPUT_CONFIG_FILE" ]]; then + options+=(-c "$INPUT_CONFIG_FILE") +fi + +if [[ -n "$INPUT_CONFIG_DATA" ]]; then + options+=(-d "$INPUT_CONFIG_DATA") +fi + +options+=(-f "$INPUT_FORMAT") + +if [[ "$INPUT_STRICT" == "true" ]]; then + options+=(-s) +fi + +# Enable globstar so ** globs recursively +shopt -s globstar # Use the current directory by default -export INPUT_FILE_OR_DIR=${INPUT_FILE_OR_DIR:-.} +options+=(${INPUT_FILE_OR_DIR:-.}) +shopt -u globstar -STRICT="" -if [ "$INPUT_STRICT" == "true" ]; then - STRICT="-s" -fi - -if [ ! -z "$INPUT_CONFIG_FILE" ]; then - CONFIG_FILE="-c $INPUT_CONFIG_FILE" -fi - -if [ ! -z "$INPUT_CONFIG_DATA" ]; then - CONFIG_DATA="-d $INPUT_CONFIG_DATA" -fi - -yamllint $CONFIG_FILE $CONFIG_DATA -f $INPUT_FORMAT $STRICT $INPUT_FILE_OR_DIR +yamllint "${options[@]}"