From 5e9865c3cf1f60f5beab542ea14cde4cf9ebd95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstro=CC=88m?= Date: Tue, 15 Jun 2021 09:05:32 -0400 Subject: [PATCH] Support Sonarqube as output formatter In Hadolint `2.5.0` the sonarqube formatter was added. This allows us to output it as part of running CI. --- README.md | 16 ++++++++-------- lib/validate.sh | 2 +- test/unit.sh | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c9077a6..7d4fea8 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ jobs: ## Parameters -| Variable | Default | Description | -| :------------ | :------------- | :---------------------------------------------------------------------------------------------------- | -| dockerfile | `./Dockerfile` | Path to Dockerfile(s). Accepts shell expansions (`**/Dockerfile`) | -| config_file | | Path to optional config (hadolint defaults to read `./hadolint.yml` if it exists) | -| error_level | `0` | Fail CI if hadolint emits output (`-1`: never, `0`: error, `1`: warning, `2`: info) | -| annotate | true | Annotate code inline in the github PR viewer (`true`/`false`) | -| output_format | | Set output format (choose between `tty`, `json`, `checkstyle`, `codeclimate` or `gitlab_codeclimate`) | -| hadolint_path | | Absolute path to hadolint binary. If unset, it is assumed to exist in `$PATH` | +| Variable | Default | Description | +| :------------ | :------------- | :----------------------------------------------------------------------------------------------------------------- | +| dockerfile | `./Dockerfile` | Path to Dockerfile(s). Accepts shell expansions (`**/Dockerfile`) | +| config_file | | Path to optional config (hadolint defaults to read `./hadolint.yml` if it exists) | +| error_level | `0` | Fail CI if hadolint emits output (`-1`: never, `0`: error, `1`: warning, `2`: info) | +| annotate | true | Annotate code inline in the github PR viewer (`true`/`false`) | +| output_format | | Set output format (choose between `tty`, `json`, `checkstyle`, `codeclimate`, `gitlab_codeclimate` or `sonarqube`) | +| hadolint_path | | Absolute path to hadolint binary. If unset, it is assumed to exist in `$PATH` | ## Hadolint version diff --git a/lib/validate.sh b/lib/validate.sh index 80a7ff1..1252e40 100644 --- a/lib/validate.sh +++ b/lib/validate.sh @@ -12,7 +12,7 @@ function validate_annotate() { } function validate_output_format() { - local -a output_formats=(tty json checkstyle codeclimate gitlab_codeclimate) + local -a output_formats=(tty json checkstyle codeclimate gitlab_codeclimate sonarqube) for format in "${output_formats[@]}"; do [[ "${format}" == "${1}" ]] && return 0 done diff --git a/test/unit.sh b/test/unit.sh index 351d816..94779bf 100755 --- a/test/unit.sh +++ b/test/unit.sh @@ -32,6 +32,7 @@ test_validate_invalid_annotate() { test_validate_output_format() { assert "validate_output_format gitlab_codeclimate" assert "validate_output_format tty" + assert "validate_output_format sonarqube" } test_validate_invalid_output_format() {