- Prerequisites
- Workflow
- Developer Docs
Please install Go 1.23.x. If you want to run TiDB Operator locally, please also install the latest version of Docker.
Visit TiDB Operator
Click Fork button (top right) to establish a cloud-based fork.
Define a local working directory:
working_dir=$GOPATH/src/github.com/pingcapSet user to match your github profile name:
user={your github profile name}Create your clone:
mkdir -p $working_dir
cd $working_dir
git clone git@github.com:$user/tidb-operator.gitSet your clone to track upstream repository.
cd $working_dir/tidb-operator
git remote add upstream https://github.com/pingcap/tidb-operatorSince you don't have write access to the upstream repository, you need to disable pushing to upstream master:
git remote set-url --push upstream no_push
git remote -vThe output should look like:
origin git@github.com:$(user)/tidb-operator.git (fetch)
origin git@github.com:$(user)/tidb-operator.git (push)
upstream https://github.com/pingcap/tidb-operator (fetch)
upstream no_push (push)Get your local master up to date:
cd $working_dir/tidb-operator
git fetch upstream
git checkout v2
git rebase upstream/v2Branch from v2:
git checkout -b myfeatureYou can now edit the code on the myfeature branch.
Sometimes you may have to re-generate code by the following commands. If you don't know whether you need to run it, just run it.
make generateRun following commands to check your code change.
make checkThis will show errors if your code change does not pass checks (e.g. unit, lint). Please fix them before submitting the PR.
At first, you must have Docker installed and running.
We use kind to start a Kubernetes cluster locally.
Run following commands to run e2e
make e2eWe use Ginkgo to write our e2e cases, So you can run a specified case by following commands
GINKGO_OPTS='--focus "regexp of case"' make e2eYou can also skip preparing e2e environment and run e2e directly by following commands
GINKGO_OPTS='--focus "regexp of case"' make e2e/runYou can see logs of operator by following commands
make logs/operatorAnd if you have some changes but just want to update operator, you can
make push && make reload/operatorYou can also deploy and re-deploy manifests by
make deployWhile on your myfeature branch, run the following commands:
git fetch upstream
git rebase upstream/v2Before you commit, make sure that all checks are passed:
make checkThen commit your changes.
git commitLikely you'll go back and edit/build/test some more than commit --amend
in a few cycles.
When your commit is ready for review (or just to establish an offsite backup of your work),
push your branch to your fork on github.com:
git push origin myfeature- Visit your fork at
https://github.com/$user/tidb-operator(replace$userobviously). - Click the
Compare & pull requestbutton next to yourmyfeaturebranch. - Edit the description of the pull request to match your change, and if your pull request introduce a user-facing change, a release note is required.
Once your pull request has been opened, it will be assigned to at least two reviewers. Those reviewers will do a thorough code review, looking for correctness, bugs, opportunities for improvement, documentation and comments, and style.
Commit changes made in response to review comments to the same branch on your fork.
Very small PRs are easy to review. Very large PRs are very difficult to review.
If you hope to submit a new feature, please see RFCs Template