...
1This directory contains CRD test fixtures, mostly intended to be used with `envtest`.
2
3By storing the fixtures here, we remove the need for each test or controller to generate and maintain these.
4
5## Generating CRDs
6
7```sh
8# generate all of them
9just update-manifest-gen
10# generate a specific set
11just run test:$target_name
12just run test:gen_edge_crds
13just run test:gen_gcp_crds
14```
15
16To see all the CRD generation targets for test fixtures:
17
18```sh
19bazel query //test/...
20```
21
22## Adding a New CRD Generation Target
23
24In `test/BUILD.bazel`:
25
26```python
27gen_manifests(
28 # name you will use when `just run ...`
29 name = "gen_my_crds",
30 crd_out_path = "test/mine",
31 # path to go package you are generating CRDs for, controller-gen
32 # will recurse into subpackages, can be in project or external (i.e. alternatively pkg = "github.com/someproject/someapis")
33 pkg = "pkg/mine/apis",
34 # tells controller-gen script to use provided crd_out_path
35 # as the full output path relative to root dir
36 relative_out_path = False,
37)
38
39# this filegroup allows you to reference all of your CRDs with one
40# label. this is useful for depending on these CRDs in a test
41filegroup(
42 name = "mine",
43 srcs = glob(["mine/*.yaml"]),
44)
45```
46
47In `test/BUILD.bazel`:
48
49Add CRD Generation directory to `embedsrcs`:
50
51```python
52go_library(
53 name = "test",
54 srcs = ["envtest.go"],
55 embedsrcs = [
56 "//test:CRDDirectoryToAdd",
57 ],
58```
View as plain text