From 912402a9535aa7575806a60680d042d47de7f085 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Tue, 7 Jun 2022 16:32:11 -0500 Subject: [PATCH 1/3] support multiple directories and files fixes: `directory` only allows for one source, not multiple #13 --- action.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index d754df0..c356f73 100755 --- a/action.yml +++ b/action.yml @@ -1,11 +1,11 @@ name: 'kube-linter' -description: 'Scan directory or file with kube-linter' +description: 'Scan directory(s) or file(s) with kube-linter' branding: icon: 'check-circle' color: 'green' inputs: directory: - description: 'Directory or file to scan' + description: 'Directory(s) or file(s) to scan' required: true config: description: 'Path to config file' @@ -65,4 +65,8 @@ runs: else CONFIG="--config ${{ inputs.config }}" fi - ./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" | tee "${{ inputs.output-file }}" + + # Perform explicit splitting into an array: + read -ra directories <<<"${{ inputs.directory }}" + + ./kube-linter $CONFIG lint "${directories[@]}" --format "${{ inputs.format }}" | tee "${{ inputs.output-file }}" From 14df1ff5347f9d8b725ee41443cb1ed227bf26a7 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Wed, 8 Jun 2022 12:08:49 -0500 Subject: [PATCH 2/3] add multiple directory test --- .github/workflows/self-test.yml | 14 +++++++++++--- README.md | 2 +- action.yml | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/self-test.yml b/.github/workflows/self-test.yml index b053044..8a37e8b 100755 --- a/.github/workflows/self-test.yml +++ b/.github/workflows/self-test.yml @@ -28,7 +28,15 @@ jobs: format: ${{ matrix.format }} version: ${{ matrix.version }} - - name: Scan 2 - should fail + - name: Scan 2 - multiple directories - should succeed + uses: ./ + with: + directory: sample/valid-yaml sample/valid-yaml + config: sample/.kube-linter-config.yaml + format: ${{ matrix.format }} + version: ${{ matrix.version }} + + - name: Scan 3 - should fail id: failing-scan uses: ./ with: @@ -38,10 +46,10 @@ jobs: version: ${{ matrix.version }} continue-on-error: true - - name: Verify Scan 2 should have failed + - name: Verify Scan 3 should have failed shell: bash run: | - echo "Verifying that kube-linter-action outcome (${{ steps.failing-scan.outcome }}) from Scan 2 is failure." + echo "Verifying that kube-linter-action outcome (${{ steps.failing-scan.outcome }}) from Scan 3 is failure." [[ "${{ steps.failing-scan.outcome }}" == "failure" ]] test-with-sarif-upload: diff --git a/README.md b/README.md index 4222ebd..8a0461d 100755 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The workflow will fail if kube-linter detects issues. You'll find issues in the | Parameter name | Required? | Description | | --- | --- | --- | -| `directory` | **(required)** | Path of file or directory to scan, absolute or relative to the root of the repo. | +| `directory` | **(required)** | Path of files or directories to scan, absolute or relative to the root of the repo. | | `config` | (optional) | Path to a [configuration file](https://docs.kubelinter.io/#/configuring-kubelinter) if you wish to use a non-default configuration. | | `format` | (optional) | Output format. Allowed values: `sarif`, `plain`, `json`. Default is `plain`. | | `output-file` | (optional) | Path to a file where kube-linter output will be stored. Default is `kube-linter.log`. File will be overwritten if it exists. | diff --git a/action.yml b/action.yml index c356f73..de5f0a0 100755 --- a/action.yml +++ b/action.yml @@ -1,11 +1,11 @@ name: 'kube-linter' -description: 'Scan directory(s) or file(s) with kube-linter' +description: 'Scan directories or files with kube-linter' branding: icon: 'check-circle' color: 'green' inputs: directory: - description: 'Directory(s) or file(s) to scan' + description: 'Directories or files to scan' required: true config: description: 'Path to config file' From b98e44532287a7eff04a06bc5fe7ec04148c336a Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Wed, 8 Jun 2022 12:12:12 -0500 Subject: [PATCH 3/3] update description to include expected format --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index de5f0a0..7c0daa4 100755 --- a/action.yml +++ b/action.yml @@ -5,7 +5,7 @@ branding: color: 'green' inputs: directory: - description: 'Directories or files to scan' + description: 'Directories or files to scan separated by spaces' required: true config: description: 'Path to config file'