Skip to main content

Developing

Guides on how to start developing on the GoKubeDownscaler.

Before you contribute to the project we would advise you to read the Contribution Manifest.

Forking the Repository

To contribute you have to fork the repository first.

To do this you have to click Fork in the top right of the repository. After that you can just follow the instructions on the page and click Create fork.

Cloning the Repository

To work on the downscaler effectively you should clone the repository onto your system. You can find instructions on how to install git on their website.

git clone https://github.com/your-username/GoKubeDownscaler.git
cd GoKubeDownscaler

Setting up Pre-Commit

Pre-Commit is a framework for running checks before committing, this ensures that formatting stays consistent, stops you from committing to protected branches (locally) and stops you from committing broken code or new functionality without updating the tests.

The recommended way to install pre-commit and the needed dependencies is via brew. If you don't have brew installed on your system you can find how to install it by following the instructions on their website.

brew install pre-commit

The Pre-Commit checks for the Downscaler have some dependencies which need to be installed manually.

brew install golangci-lint
brew install gofumpt

Alternative Installation

Alternatively you can install pre-commit and the dependencies manually. Installation instructions for pre-commit can be found on their website. Additionally you will need to install golangci-lint and gofumpt as dependencies for the pre-commit checks of the downscaler.

Enabling Pre-Commit

Next we will have to enabling pre-commit for the repository. Make sure you are in the GoKubeDownscaler git repository.

pre-commit install

Running Pre-Commit Manually

Sometimes it can be useful to run pre-commit without also committing or just letting it run on all files instead of just the changed ones.

This command lets you start a pre-commit run on all files manually:

pre-commit run --all-files

Skipping Pre-Commit Checks Temporarily

Pre-Commit normally shouldn't be ignored, but in some cases you might need to skip some or all pre-commit checks temporarily. All checks will run in the pre-commit workflow once you push your changes and haven't resolved the issues.

To disable one or multiple checks:

SKIP=prevent-todo-comments,another-check-id-here pre-commit run --all-files

or

SKIP=prevent-todo-comments,another-check-id-here git commit

If you need to disable all checks you can run this to skip all git hooks:

git commit --no-verify

Overview