Skip to content

Add pre-commit configuration to run kubeconform#349

Open
ellieayla wants to merge 1 commit into
yannh:masterfrom
ellieayla:add-pre-commit-config
Open

Add pre-commit configuration to run kubeconform#349
ellieayla wants to merge 1 commit into
yannh:masterfrom
ellieayla:add-pre-commit-config

Conversation

@ellieayla
Copy link
Copy Markdown

Contribute a pre-commit hook specification, so https://pre-commit.com/ can discover how to run kubeconform.

Usage, in a project's .pre-commit-config.yaml

 - repo: https://github.com/yannh/kubeconform
   rev: v0.7.1  # pinned (future) version of kubeconform

   hooks:
   - id: kubeconform
     name: kubeconform run with defaults

   - id: kubeconform
     name: kubeconfirm run with 8 goroutines and extra schemas from crd catalog
     args:
     - -strict # disallow additional properties not in schema or duplicated keys

     # Look in both the default & contributed CRDs-catalog for schemas
     - -schema-location
     - default
     - -schema-location
     - 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'

     # skip CRDs and Kustomization resources
     - -skip
     - CustomResourceDefinition,Kustomization

     # parallel
     - -n
     - "8"

$ pre-commit run --files default/whoami.yaml --verbose kubeconform

kubeconform run with defaults..............................................................Failed
- hook id: kubeconform
- duration: 0.36s
- exit code: 1

default/whoami.yaml - IngressRoute whoami failed validation: could not find schema for IngressRoute

kubeconfirm run with 8 goroutines and extra schemas from crd catalog.......................Failed
- hook id: kubeconform
- duration: 0.24s
- exit code: 1

default/whoami.yaml - IngressRoute whoami is invalid: problem validating schema. Check JSON formatting: jsonschema validation failed with 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/traefik.io/ingressroute_v1alpha1.json#' - at '/spec': additional properties 'middlewares-spelling-mistake' not allowed

Contribute a pre-commit hook specification, so https://pre-commit.com/ can discover how to run kubeconform.
@ellieayla
Copy link
Copy Markdown
Author

Just noticed that this idea was also proposed in #198 -- they're not identical changes. Probably only want to merge one & reject the other.

@lalten
Copy link
Copy Markdown

lalten commented Mar 30, 2026

@yannh would be great to land this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants