@@ -4,7 +4,7 @@ These bazel rules download and make available the [Kubebuilder SDK](https://gith
44
55To use these rules, add the following to your ` WORKSPACE ` file:
66
7- ```
7+ ``` starlark
88load(" @bazel_tools//tools/build_defs/repo:git.bzl" , " git_repository" )
99
1010git_repository(
@@ -28,7 +28,7 @@ kustomize_register_toolchain()
2828
2929And in your ` go_test() ` files, add ` etcd ` as a data dependency like this:
3030
31- ```
31+ ``` starlark
3232go_test(
3333 name = " go_default_test" ,
3434 srcs = [" apackage_test.go" ],
@@ -42,28 +42,28 @@ go_test(
4242```
4343You'll need to run the test as:
4444
45- ```
45+ ``` shell
4646bazel test --test_env=KUBEBUILDER_ASSETS=$( bazel info execution_root 2> /dev/null) /$( bazel run @kubebuilder_sdk//:pwd 2> /dev/null) //...
4747```
4848
4949You can also add the following to ` BUILD.bazel ` at the root of your workspace:
5050
51- ```
51+ ``` starlark
5252load(" @rules_kubebuilder//kubebuilder:def.bzl" , " kubebuilder" )
5353kubebuilder(name = " kubebuilder" )
5454```
5555
5656to be able to run ` kubebuilder ` like so:
5757
58- ```
59- $ bazel run //:kubebuilder -- --help
58+ ``` shell
59+ bazel run //:kubebuilder -- --help
6060```
6161
6262## Controller-gen
6363
6464In order to use ` controller-gen ` you will need to do something like the following in your ` api/v1alpha1 ` directory (essentially where the ` *_type.go ` files are):
6565
66- ```
66+ ``` starlark
6767load(" @io_bazel_rules_go//go:def.bzl" , " go_library" )
6868load(
6969 " @rules_kubebuilder//controller-gen:controller-gen.bzl" ,
@@ -126,8 +126,8 @@ they can be used. Fortunately Go supports cross compiling so in order to build t
126126need to get and install Go either from [ their download page] ( https://golang.org/doc/install ) or from
127127homebrew by running
128128
129- ```
130- $ brew install golang
129+ ``` shell
130+ brew install golang
131131```
132132
133133After that you can run the script in ` scripts/build-controller-gen.sh ` which will compile ` controller-gen `
0 commit comments