This guide is for developers who want to improve Draft. These instructions will help you set up a development environment for working on the Draft source code.
To compile and test Draft binaries and to build Docker images, you will need:
- a Kubernetes cluster. We recommend minikube.
- docker
- git
- helm, using the same version as recommended in the installation guide.
- Go 1.8 or later, with support for compiling to
linux/amd64
- upx (optional) to compress binaries for a smaller Docker image
In most cases, install the prerequisite according to its instructions. See the next section for a note about Go cross-compiling support.
Draft's binary executables are built on your machine and then copied into a Docker image. This
requires your Go compiler to support the linux/amd64
target architecture. If you develop on a
machine that isn't AMD64 Linux, make sure that go
has support for cross-compiling.
On macOS, a cross-compiling Go can be installed with Homebrew:
$ brew install go --with-cc-common
It is also straightforward to build Go from source:
$ sudo su
$ curl -sSL https://storage.googleapis.com/golang/go1.10.src.tar.gz | tar -C /usr/local -xz
$ cd /usr/local/go/src
$ # compile Go for the default platform first, then add cross-compile support
$ ./make.bash --no-clean
$ GOOS=linux GOARCH=amd64 ./make.bash --no-clean
Begin at Github by forking Draft, then clone your fork locally. Since Draft is a Go package, it
should be located at $GOPATH/src/github.com/Azure/draft
.
$ mkdir -p $GOPATH/src/github.com/Azure
$ cd $GOPATH/src/github.com/Azure
$ git clone [email protected]:<username>/draft.git
$ cd draft
Add the conventional upstream git
remote in order to fetch changes from Draft's main master
branch and to create pull requests:
$ git remote add upstream https://github.com/Azure/draft.git
With the prerequisites installed and your fork of Draft cloned, you can make changes to local Draft source code.
Run make
to build draft
:
$ make bootstrap
$ make
Draft includes a suite of tests.
make test-lint
: runs linter/style checksmake test-unit
: runs basic unit testsmake test
: runs all of the above
$ make clean