This guide is intended for people who want to start working on
If you intend to write a new plugin, see Developer Guide
Setting up the environment
Krew is built with go 1.10, but newer versions will do as well.
Most toolchains will expect that the krew repository is on the
To set it up correctly, do
mkdir -p $(go env GOPATH)/src/sigs.k8s.io/krew cd $(go env GOPATH)/src/sigs.k8s.io/krew git clone https://github.com/kubernetes-sigs/krew . git remote set-url origin --push no_push # to avoid pushes
Krew adheres to standard
golang code formatting conventions, and also expects
imports sorted properly.
To automatically format code appropriately, install
go get golang.org/x/tools/cmd/goimports
goimports -w cmd pkg
In addition, a boilerplate license header is expected in all source files.
All new code should be covered by tests.
To run tests locally, the easiest way to get started is with
This will run all unit tests and code quality tools.
To run a single tool independently of the other code checks, have a look at the
other scripts in
In addition, there are integration tests to cover high-level krew functionality.
To run integration tests, you will need to build the
krew binary beforehand:
krew in a sandbox
After making changes to krew, you should also check that it behaves as expected.
You can do this without messing up the krew installation on the host system by
KREW_ROOT environment variable.
mkdir playground KREW_ROOT="$PWD/playground" krew update
Any changes that krew is going to apply will then be applied in the
playground/ folder, instead of the standard
Testing in a docker sandbox
Alternatively, if the isolation provided by
KREW_ROOT is not enough, there is
also a script to run krew in a docker sandbox: