Skip to content

[Feature Request] Add a pre-commit hook for running kube-score #658

@erNail

Description

@erNail

Feature Request

Motivation / Problem

I'd like to run kube-score as part of my pre-commit setup.

pre-commit is a popular tool for bundling the execution of multiple linters. pre-commit can then be run via Git Hooks, manually via pre-commit run, or in CI/CD Pipelines.

A lot of popular linters like golangci-lint, yamllint or kube-linter provide pre-commit hooks in their repos, configured via a .pre-commit-hooks.yaml

Proposed solution

Adding pre-commit hooks is fairly simple. All you need is a .pre-commit-hooks.yaml in your repository.
For a go application, it could look like this:

---
- id: "kube-score"
  name: "Run kube-score"
  description:
    "This hook installs and runs `kube-score` to perform static code analysis of your Kubernetes object definitions"
  language: "golang"
  types:
    - "yaml"
  entry: "kube-score score"

- id: "kube-score-system"
  name: "Run kube-score from system"
  description:
    "This hook runs `kube-score` from your system to perform static code analysis of your Kubernetes object definitions"
  language: "system"
  entry: "kube-score score"
  types:
    - "yaml"

- id: "kube-score-docker"
  name: "Run kube-score via container"
  description:
    "This hook runs `kube-score` via container to perform static code analysis of your Kubernetes object definitions"
  language: "docker_image"
  types:
    - "yaml"
  entry: "zegl/kube-score:latest score"
...

Additional information

I've created a Pull Request: #659

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions