datreeio / datree

Prevent Kubernetes misconfigurations from reaching production (again šŸ˜¤ )! From code to cloud, Datree provides an E2E policy enforcement solution to run automatic checks for rule violations. See our docs: https://hub.datree.io
https://datree.io
Apache License 2.0
6.39k stars 363 forks source link

[BUG] pre-commit hooks seems to ignore custom schema locations #973

Closed fredleger closed 6 months ago

fredleger commented 8 months ago

Describe the bug When using pre-commit hooks i had bad time trying to add custom schema locations

To Reproduce Steps to reproduce the behavior:

  1. Setup the following commit hook config
[...]
  - repo: https://github.com/datreeio/datree
    rev: 1.9.19
    hooks:
      - id: datree-system
        exclude: |
          (?x)^(
            ^\.github/.*|
            ^\.datree/.*|
            ^\.pre-commit-config.yaml
          )$
        args:
          - "test"
          - --no-record
          - --verbose
          - --schema-version=1.23.0
          - --schema-location='https://raw.githubusercontent.com/webofmars/CRDs-catalog/main/crds/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
[...]
  1. run pre-commit install
  2. run pre-commit run -a datree-system on a repo with a manifest not known by default to datree (for my case ops.alexellis.io/clusterpullsecret/v1)

image

If i run the same command on pure command line (hence without pre-commit hook implied) :

image

Expected behavior schema locations should be easy to use with pre-commit hooks

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Datree version (run datree version):

Client ID (cat ~/.datree/config.yaml):

Additional context

Running in offline mode but i guess this is not an issue here

fredleger commented 8 months ago

Note: I actually tried running it without mode offline or with a local folder .datree inside the git repo and got the same behavior

ex: --schema-location='.datree/crdSchemas/{{.Group}}/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json'

github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.