Skip to content

Commit 4df5432

Browse files
author
Phillip Wittrock
authored
Merge pull request #212 from Liujingfang1/master
add README.md for sample projects
2 parents 69bb4ac + 1219317 commit 4df5432

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

samples/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Sample Project
2+
3+
Sample project is a project that created by kubebuilder and moved into `samples` folder. It contains resources and controllers. The main purpose of sample projects is to test and validate the behavior of kubebuilder. Specifically, the new built kubebuilder commands don't break existing projects created by older version of kubebuilder commands.
4+
5+
## Current Sample Projects
6+
- memcached-api-apiserver
7+
8+
## Test Sample Project
9+
Run following command to test a sample project such as memcached-api-apiserver
10+
```
11+
go test -v ./samples/memcached-api-apiserver
12+
```
13+
14+
## Add Sample Project
15+
We can test different aspects of kubebuilder in different sample projects. For example, we can test and validate how kubebuilder handles validation annotations in one sample project and validate how kubebuilder handles rbac rules in a different sample project. Here are steps to add a new project.
16+
17+
- Create a new subdirectory under samples to hold the new sample project and change directory to it
18+
- run `kubebuilder init` to init a project
19+
- run `kubebuilder create resource` to create resources you want to add
20+
- Update the resource or controller files for your test purpose. For example, add validation annotations in resource file.
21+
- Create the expected files under `test`. For example, memcached-api-server has an expected file `test/hack/install.yaml`, which is used to compare with the output of `kubebuilder create config`.
22+
- Write `<project>_test.go` file to test the new sample project similar to memcached_test.go.
23+
24+

0 commit comments

Comments
 (0)