diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 6332ad6..c72d6a8 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -13,7 +13,7 @@ env: MATRIX: >- [ { - "NAME": "jsonlint", + "NAME": "jl", "VERSION": ["latest", "1.6.0"], "FLAVOUR": ["alpine", "latest"], "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] diff --git a/Dockerfiles/data/docker-entrypoint.sh b/Dockerfiles/data/docker-entrypoint.sh index 2583b57..d4db53b 100755 --- a/Dockerfiles/data/docker-entrypoint.sh +++ b/Dockerfiles/data/docker-entrypoint.sh @@ -28,6 +28,8 @@ print_usage() { >&2 echo " -t CHAR character(s) to use for indentation" >&2 echo " -i Ignore glob pattern when using the GLOB-PATTERN for file search." >&2 echo " (e.g.: -i '\.terraform*.json')" + >&2 echo " Multiple ignores can be comma separated:" + >&2 echo " (e.g.: -i '\.terraform*.json,*test.json')" >&2 echo " Path to file to validate" >&2 echo " Glob pattern for recursive scanning. (e.g.: *\\.json)" >&2 echo " Anything that \"find . -name ''\" will take is valid." @@ -137,7 +139,7 @@ if [ "${#}" -gt "0" ]; then if [ -z "${ARG_IGNORE}" ]; then find_cmd="find . -name \"${1}\" -type f -print0" else - find_cmd="find . -not \( -path \"${ARG_IGNORE}\" \) -name \"${1}\" -type f -print0" + find_cmd="find . -not \( -path \"${ARG_IGNORE//,/*\" -o -path \"}*\" \) -name \"${1}\" -type f -print0" fi echo "${find_cmd}" diff --git a/Makefile b/Makefile index 0629f32..373cef6 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ TAG = latest # Makefile.docker overwrites NAME = jsonlint VERSION = latest -IMAGE = cytopia/${NAME} +IMAGE = cytopia/jsonlint FLAVOUR = latest FILE = Dockerfile.${FLAVOUR} DIR = Dockerfiles @@ -136,7 +136,11 @@ _test-run: @echo "------------------------------------------------------------" @echo "- Testing playbook" @echo "------------------------------------------------------------" - if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests:/data $(IMAGE):$(DOCKER_TAG) -t ' ' *.json ; then \ + if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests:/data $(IMAGE):$(DOCKER_TAG) -t ' ' test.json ; then \ + echo "Failed"; \ + exit 1; \ + fi; \ + if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests:/data $(IMAGE):$(DOCKER_TAG) -t ' ' -i '*1.json,*2.json' *.json ; then \ echo "Failed"; \ exit 1; \ fi; \ diff --git a/README.md b/README.md index ad41a53..21d66fb 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ Usage: cytopia/jsonlint [-sti] -t CHAR character(s) to use for indentation -i Ignore glob pattern when using the GLOB-PATTERN for file search. (e.g.: -i '\.terraform*.json') + Multiple ignores can be comma separated: + (e.g.: -i '\.terraform*.json,*test.json') Path to file to validate Glob pattern for recursive scanning. (e.g.: *\.json) Anything that "find . -name ''" will take is valid. diff --git a/tests/fail-1.json b/tests/fail-1.json new file mode 100644 index 0000000..1f8a567 --- /dev/null +++ b/tests/fail-1.json @@ -0,0 +1,4 @@ +{ + "key": "value", + "foo": "bar"a +} diff --git a/tests/fail-2.json b/tests/fail-2.json new file mode 100644 index 0000000..1f8a567 --- /dev/null +++ b/tests/fail-2.json @@ -0,0 +1,4 @@ +{ + "key": "value", + "foo": "bar"a +}