This doc explains how to set up a development environment so you can get started
contributing to Knative Client
. Also
take a look at:
Follow the instructions below to set up your development environment. Once you meet these requirements, you can make changes and build your own version of Knative Client!
Before submitting a PR, see also contribution guide.
Start by creating a GitHub account, then set up GitHub access via SSH.
You must install these tools:
go
: The languageKnative Client
is built in (1.13 or later)goimports
gcc
compiler: Used during testing. Not needed if golang is installed via the installergit
: For source controlkubectl
: For managing development environments
To check out this repository:
- Create your own fork of this repo
- Clone it to your machine:
git clone git@github.com:${YOUR_GITHUB_USERNAME}/client.git
cd client
git remote add upstream git@github.com:knative/client.git
git remote set-url --push upstream no_push
Adding the upstream
remote sets you up nicely for regularly
syncing your fork.
Once you reach this point you are ready to do a full build and test as described below.
Once you've set up your development environment, let's build
Knative Client
.
Dependencies:
go mod is used and required for dependencies.
Building:
$ hack/build.sh
You can link that script into a directory within your search $PATH
. This
allows you to build kn
from any working directory. There are several options
to support various development flows:
build.sh
- Compile, test, generate docs and format source codebuild.sh -f
- Compile onlybuild.sh -f -t
- Compile & testbuild.sh -c
- Update dependencies, regenerate documentation and format source filesbuild.sh -w
- Enter watch mode for automatic recompilationbuild.sh -w -t
- Enter watch mode for automatic recompilation & running tests
See build.sh --help
for a full list of options and usage examples.
In the end, the build results in kn
binary in your current directory, which
can be directly executed.
Testing:
Please follow the guide here to test the knative client
.
Notes:
- For building, Go
1.11.4
is required due to a go mod issue. - If you are building in your
$GOPATH
folder, you need to specifyGO111MODULE
for building it
# if you are building in your $GOPATH
GO111MODULE=on go build ./cmd/...
You can now try updating code for client and test out the changes by building
the kn
binary.