Skip to content

Commit

Permalink
Merge pull request #19 from cytopia/feature-ignore-pattern
Browse files Browse the repository at this point in the history
Feature ignore pattern
  • Loading branch information
cytopia committed Oct 22, 2022
2 parents 64c4f4a + 4fe54f6 commit a21c962
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 3 additions & 1 deletion Dockerfiles/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ print_usage() {
>&2 echo " -t CHAR character(s) to use for indentation"
>&2 echo " -i <GLOB-PATTERN> 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> Path to file to validate"
>&2 echo " <GLOB-PATTERN> Glob pattern for recursive scanning. (e.g.: *\\.json)"
>&2 echo " Anything that \"find . -name '<GLOB-PATTERN>'\" will take is valid."
Expand Down Expand Up @@ -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}"
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Usage: cytopia/jsonlint [-sti] <PATH-TO-FILE>
-t CHAR character(s) to use for indentation
-i <GLOB-PATTERN> 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> Path to file to validate
<GLOB-PATTERN> Glob pattern for recursive scanning. (e.g.: *\.json)
Anything that "find . -name '<GLOB-PATTERN>'" will take is valid.
Expand Down
4 changes: 4 additions & 0 deletions tests/fail-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key": "value",
"foo": "bar"a
}
4 changes: 4 additions & 0 deletions tests/fail-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key": "value",
"foo": "bar"a
}

0 comments on commit a21c962

Please sign in to comment.