Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple directories and files #15

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: 'kube-linter'
description: 'Scan directory or file with kube-linter'
description: 'Scan directories or files with kube-linter'
branding:
icon: 'check-circle'
color: 'green'
inputs:
directory:
description: 'Directory or file to scan'
description: 'Directories or files to scan separated by spaces'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On one hand I like this simple approach of accepting space separated list of dirs but on the other the more natural for yaml will be an array. Can we accept array and us jq to parse it? Does it make sense?

required: true
config:
description: 'Path to config file'
Expand Down Expand Up @@ -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 }}"