We use pre-commit to ensure that our code meets various standards and best-practices. Pre-commit is a tool that will run checks against a codebase on every commit. If any of these checks fail, you have two options:
- Manually resolve the issues: Review the error messages provided by the hooks and fix the problems in your codebase.
- Let the hooks fix the issues: In some cases, the hooks will automatically update your code to meet the required standards. If this happens, simply stage the changes and attempt the commit again.
This ensures that your code adheres to the project's conventions before being committed.
Our repository has a configuration file called .pre-commit-config.yaml, located in the root directory of the repository.
This contains all of the instructions and extensions to use with pre-commit.
To get started with pre-commit, follow these steps:
-
Install
pre-commit:You can install it using
pipwith the commandpip install pre-commit. For more details, refer to thepre-commitinstallation instructions. -
Activate
pre-commitin the repository:To activate pre-commit, run the following command:
pre-commit install
This will check the
.pre-commit-config.yamlfile and install the needed dependencies for this repository.
With this setup, pre-commit will now automatically run checks on every commit.
You may also manually run it with the following command:
pre-commit runBy default, pre-commit will only run on the changed files in a commit. To run it for all files at once, use the following command:
pre-commit run --all-filesWe use Kubebuilder to scaffold and manage Kubernetes APIs/controllers. For local development and code generation, we require a pinned version:
- Version: 4.9.0
- Release notes: https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v4.9.0
For detailed information, please take a look at Kubebuilder's installation instructions to get the installation guide for your platform. For reference, to validate your Kubebuilder version, type the following command:
kubebuilder versionThe output should look like something like this:
❯ kubebuilder version
Version: cmd.version{KubeBuilderVersion:"4.9.0", KubernetesVendor:"1.34.0", GitCommit:"5e331e74c7a25c8e8fc0d9d5c33c319b7268f395", BuildDate:"2025-09-22T10:53:21Z", GoOs:"linux", GoArch:"amd64"}