Before continuing, make sure you've read the README
This is a (probably incomplete) list of software used to develop the operator:
golang >= v1.13
...the operator is written in it...operator-sdk
Provides all the plumbing and project structurehelm
Used to deploy and test the operator on a kubernetes clusterpre-commit
Used to ensure all files are formatted, generated code is up to date and moregofumpt
Used for code formattinggolangci-lint
Lints for go code
Some additional software you may find useful:
virter
can create virtual machines (for example a virtual kubernetes cluster)cfssl
can create TLS certificates from json configs
Commit hooks ensure that all new and changed code is formatted and tested before committing. To set up commit hooks
install pre-commit
(see above) and run:
$ pre-commit install
Now, if you try to commit a file that for example is not properly formatted, you will receive a message like:
$ git commit -a -m "important fix; no time to check for errors"
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...........................................(no files to check)Skipped
Check for added large files..............................................Passed
gofumpt..................................................................Failed
- hook id: gofumpt
- exit code: 1
- files were modified by this hook
version/version.go
golangci-lint............................................................Failed
- hook id: golangci-lint
- exit code: 1
For basic unit testing use the basic go test framework. If something you want to test relies on the Kubernetes API (and can't be refactored), you can try to test with a fake client.
As of right now, there is no recommended way to end-to-end test the operator. It probably involves some virtual machines running a basic kubernetes cluster.
On every pull request, we run a set of tests, specified in .github/workflows
. The checks include
go test
golandci-lint
pre-commit run