stackrox / kube-linter

KubeLinter is a static analysis tool that checks Kubernetes YAML files and Helm charts to ensure the applications represented in them adhere to best practices.

Home Page:https://docs.kubelinter.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE_REQUEST]: Allow for multiple custom checks at once

ohnickmoy opened this issue · comments

Description of the problem/feature request
Allow for multiple custom checks at once. If utilizing multiple custom checks at once is already available, make it apparent in the documentation how to do it

Description of the existing behavior vs. expected behavior
Output of github action after attempting to do multiple checks below. It's clear in the docs how syntax is written for one custom check, but what's the best way to do multiple?

Run stackrox/kube-linter-action@v[1](https://github.com/edx/edx-internal/actions/runs/3315200215/jobs/5475477031#step:5:1).0.4
Run set -u
Run set -u
Error: failed to load config: reading file: While parsing config: yaml: unmarshal errors:
  line 26: mapping key "name" already defined at line 19
  line 27: mapping key "template" already defined at line 20
  line 2[8](https://github.com/edx/edx-internal/actions/runs/3315200215/jobs/5475477031#step:5:9): mapping key "params" already defined at line 21
Error: Process completed with exit code 1.

Additional context
Custom checks block i'm trying out is currently written out as follows:

customChecks:
  - name: image-tags-block
    template: latest-tag
    params:
      BlockList: 
      - .*:(latest)$
      - ^[^:]*$
      - (.*/[^:]+)$
  - name: image-tags-allow
    template: latest-tag
    params:
      AllowList:
      - .*:(alpine)$
      - ^[^:]*$
      - (.*/[^:]+)$

if there's an alternative way to write them, please point it out.

Hey, I could not reproduce your issue. Could you add more details?

➜  kube-linter git:(main): cat test.yml 
customChecks:
  - name: image-tags-block
    template: latest-tag
    params:
      BlockList: 
      - .*:(latest)$
      - ^[^:]*$
      - (.*/[^:]+)$
  - name: image-tags-allow
    template: latest-tag
    params:
      AllowList:
      - .*:(alpine)$
      - ^[^:]*$
      - (.*/[^:]+)$

➜  kube-linter git:(main): ./bin/linux/kube-linter lint tests/testdata/  --config test.yml --do-not-auto-add-defaults
KubeLinter 0.5.0-18-gbd11843210

tests/testdata/splunk.yaml: (object: splunk-ns/splunk apps/v1, Kind=Deployment) The container "splunk" is using an invalid container image, "splunk/splunk:8.1.2". Please use images that satisfies the `AllowList` criteria : [".*:(alpine)$" "^[^:]*$" "(.*/[^:]+)$"] (check: image-tags-allow, remediation: )

tests/testdata/mychart/templates/deployment.yaml: (object: <no namespace>/test-release-mychart apps/v1, Kind=Deployment) The container "mychart" is using an invalid container image, "nginx:1.16.0". Please use images that satisfies the `AllowList` criteria : [".*:(alpine)$" "^[^:]*$" "(.*/[^:]+)$"] (check: image-tags-allow, remediation: )

tests/testdata/mychart/templates/tests/test-connection.yaml: (object: <no namespace>/test-release-mychart-test-connection /v1, Kind=Pod) The container "wget" is using an invalid container image, "busybox". Please use images that are not blocked by the `BlockList` criteria : [".*:(latest)$" "^[^:]*$" "(.*/[^:]+)$"] (check: image-tags-block, remediation: )

tests/testdata/mychart-0.1.0.tgz/mychart/templates/deployment.yaml: (object: <no namespace>/test-release-mychart apps/v1, Kind=Deployment) The container "mychart" is using an invalid container image, "nginx:1.16.0". Please use images that satisfies the `AllowList` criteria : [".*:(alpine)$" "^[^:]*$" "(.*/[^:]+)$"] (check: image-tags-allow, remediation: )

tests/testdata/mychart-0.1.0.tgz/mychart/templates/tests/test-connection.yaml: (object: <no namespace>/test-release-mychart-test-connection /v1, Kind=Pod) The container "wget" is using an invalid container image, "busybox". Please use images that are not blocked by the `BlockList` criteria : [".*:(latest)$" "^[^:]*$" "(.*/[^:]+)$"] (check: image-tags-block, remediation: )

Error: found 5 lint errors

gonna close this. couldn't find exact issue but i bet it was formatting or white space