mirror of
https://github.com/stackrox/kube-linter-action.git
synced 2026-07-04 23:51:37 +00:00
add support for fail-on-invalid-resource (#29)
This commit is contained in:
@@ -73,3 +73,28 @@ jobs:
|
||||
|
||||
- name: Upload SARIF output file to GitHub
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
|
||||
test-fail-on-invalid-resource:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Scan 1 - should succeed
|
||||
uses: ./
|
||||
with:
|
||||
directory: sample/non-kubernetes-yaml
|
||||
config: sample/.kube-linter-config.yaml
|
||||
|
||||
- name: Scan 2 - should fail
|
||||
id: failing-scan
|
||||
uses: ./
|
||||
with:
|
||||
directory: sample/non-kubernetes-yaml
|
||||
config: sample/.kube-linter-config.yaml
|
||||
fail-on-invalid-resource: "true"
|
||||
continue-on-error: true
|
||||
|
||||
- name: Verify Scan 2 should have failed
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Verifying that kube-linter-action outcome (${{ steps.failing-scan.outcome }}) from Scan 2 is failure."
|
||||
[[ "${{ steps.failing-scan.outcome }}" == "failure" ]]
|
||||
|
||||
@@ -35,3 +35,4 @@ The workflow will fail if kube-linter detects issues. You'll find issues in the
|
||||
| `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. |
|
||||
| `version` | (optional) | kube-linter release version to use, e.g. "0.2.4". The latest available version is used by default. |
|
||||
| `fail-on-invalid-resource` | (optional) | Set `true` to error out when we have an invalid resource. |
|
||||
|
||||
+12
-1
@@ -22,6 +22,10 @@ inputs:
|
||||
description: 'Version of kube-linter to use. E.g. "0.2.4". Default: "latest"'
|
||||
required: false
|
||||
default: 'latest'
|
||||
fail-on-invalid-resource:
|
||||
description: 'Error out when we have an invalid resource. Default: false'
|
||||
required: false
|
||||
default: 'false'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -65,4 +69,11 @@ runs:
|
||||
else
|
||||
CONFIG="--config ${{ inputs.config }}"
|
||||
fi
|
||||
./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" | tee "${{ inputs.output-file }}"
|
||||
|
||||
if [[ "${{ inputs.fail-on-invalid-resource }}" == "true" ]]; then
|
||||
FLAG_ARGS="--fail-on-invalid-resource "
|
||||
else
|
||||
FLAG_ARGS=""
|
||||
fi
|
||||
|
||||
./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" $FLAG_ARGS | tee "${{ inputs.output-file }}"
|
||||
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
food:
|
||||
- vegetables: tomatoes
|
||||
Reference in New Issue
Block a user