This doc explains how to setup a development environment so you can get started
contributing to Knative-GCP
. Also take a look at:
- The pull request workflow
- How to add and run e2e tests
- Iterating
- Format check
- Additional development documentation
The Go tools require that you clone the repository to the
src/github.com/google/knative-gcp
directory in your
GOPATH
.
To check out this repository:
- Create your own fork of this repo
- Clone it to your machine:
mkdir -p ${GOPATH}/src/github.com/google
cd ${GOPATH}/src/github.com/google
git clone git@github.com:${YOUR_GITHUB_USERNAME}/knative-gcp.git
cd knative-gcp
git remote add upstream https://github.com/google/knative-gcp.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 deploy as follows.
As you make changes to the code-base, there are two cases to be aware of(If you run under macOS, you may need to upgrade your bash version on macOS since macOS comes with bash version 3 which is quite limiting and lack features need to run the following two scripts):
- If you change a type definition (pkg/apis/), then you must
run
./hack/update-codegen.sh
. - If you change a package's deps (including adding external dep), then you
must run
./hack/update-deps.sh
.
These are both idempotent, and we expect that running these at HEAD
to have no
diffs.
Once the codegen and dependency information is correct, redeploying the controller is simply:
ko apply -f config/500-controller.yaml
Or you can clean it up completely and start again.
The CI/CD runs format check, please run these commands before you submit a code change to make sure the format follows the standard: For macOS:
find . -name '*.go' \! -name wire_gen.go \! -name '*.pb.go' -exec go run golang.org/x/tools/cmd/goimports -w {} \+ -o \( -path ./vendor -o -path ./third_party \) -prune
find . -name '*.go' -type f \! -name '*.pb.go' -exec gofmt -s -w {} \+ -o \( -path './vendor' -o -path './third_party' \) -prune
For Linux:
find -name '*.go' \! -name wire_gen.go \! -name '*.pb.go' -exec go run golang.org/x/tools/cmd/goimports -w {} \+ -o \( -path ./vendor -o -path ./third_party \) -prune
find -name '*.go' -type f \! -name '*.pb.go' -exec gofmt -s -w {} \+ -o \( -path './vendor' -o -path './third_party' \) -prune
Running E2E tests as you make changes to the code-base is pretty simple. See E2E test docs.
You can delete Knative-GCP
with:
ko delete -f config/