Skip to content

Commit c5e9e22

Browse files
authored
Merge pull request #875 from DirectXMan12/docs/autogen-marker-docs
📖 Marker Docs
2 parents ea6a7ee + 7a8ee61 commit c5e9e22

File tree

28 files changed

+1304
-152
lines changed

28 files changed

+1304
-152
lines changed

docs/book/book.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ curly-quotes = true
1010

1111
[preprocessor.literatego]
1212
command = "./litgo.sh"
13+
14+
[preprocessor.markerdocs]
15+
command = "./markerdocs.sh"

docs/book/install-and-build.sh

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
11
#!/bin/bash
22

3+
set -e
4+
35
os=$(go env GOOS)
46
arch=$(go env GOARCH)
57

8+
# translate arch to rust's conventions (if we can)
9+
if [[ ${arch} == "amd64" ]]; then
10+
arch="x86_64"
11+
elif [[ ${arch} == "x86" ]]; then
12+
arch="i686"
13+
fi
14+
15+
# translate os to rust's conventions (if we can)
16+
ext="tar.gz"
17+
cmd="tar -C /tmp -xzvf"
18+
case ${os} in
19+
windows)
20+
target="pc-windows-msvc"
21+
ext="zip"
22+
cmd="unzip -d /tmp"
23+
;;
24+
darwin)
25+
target="apple-darwin"
26+
;;
27+
linux)
28+
# works for linux, too
29+
target="unknown-${os}-gnu"
30+
;;
31+
*)
32+
target="unknown-${os}"
33+
;;
34+
esac
35+
636
# grab mdbook
7-
# mdbook's deploy got borked by a CI move, so grab our build till that gets
8-
# fixed (https://github.com/rust-lang-nursery/mdBook/issues/904).
9-
curl -sL -o /tmp/mdbook https://storage.googleapis.com/kubebuilder-build-tools/mdbook-0.2.3-${os}-${arch}
37+
# we hardcode linux/amd64 since rust uses a different naming scheme and it's a pain to tran
38+
echo "downloading mdBook-v0.3.1-${arch}-${target}.${ext}"
39+
set -x
40+
curl -sL -o /tmp/mdbook.${ext} https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdBook-v0.3.1-${arch}-${target}.${ext}
41+
${cmd} /tmp/mdbook.${ext}
1042
chmod +x /tmp/mdbook
43+
44+
echo "grabbing the latest released controller-gen"
45+
# TODO(directxman12): remove the @v0.2.0-beta.4 once get v0.2.0 released,
46+
# so that we actually get the latest version
47+
go get sigs.k8s.io/controller-tools/cmd/[email protected]
48+
49+
# make sure we add the go bin directory to our path
50+
gobin=$(go env GOBIN)
51+
gobin=${GOBIN:-$(go env GOPATH)/bin} # GOBIN won't always be set :-/
52+
53+
export PATH=${gobin}:$PATH
1154
/tmp/mdbook build

docs/book/litgo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ex
44

55
(
66
pushd ./utils
7-
go build -o ../../../bin/literate-go ./literate.go
7+
go build -o ../../../bin/literate-go ./litgo
88
popd
99
) &>/dev/null
1010

docs/book/markerdocs.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
(
6+
pushd ./utils
7+
go build -o ../../../bin/marker-docs ./markerdocs
8+
popd
9+
) &>/dev/null
10+
11+
../../bin/marker-docs "$@"

docs/book/src/SUMMARY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
- [Kind cluster](reference/kind.md)
4343
- [What's a webhook?](reference/webhook-overview.md)
4444
- [Admission webhook](reference/admission-webhook.md)
45+
- [Markers for Config/Code Generation](./reference/markers.md)
46+
47+
- [CRD Generation](./reference/markers/crd.md)
48+
- [CRD Validation](./reference/markers/crd-validation.md)
49+
- [Webhook](./reference/markers/webhook.md)
50+
- [Object/DeepCopy](./reference/markers/object.md)
51+
- [RBAC](./reference/markers/rbac.md)
52+
4553
---
4654

4755
[Appendix: The TODO Landing Page](./TODO.md)

docs/book/src/cronjob-tutorial/epilogue.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
Things left to do:
44

55
- Write custom printer columns
6-
- Discuss webhooks
76
- Use different watches

docs/book/src/cronjob-tutorial/testdata/emptycontroller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ type CronJobReconciler struct {
4444
}
4545

4646
/*
47-
Most controllers eventually end up running on the cluster, so they need RBAC permissions.
48-
These are the bare minimum permissions needed to run. As we add more functionality, we'll
49-
need to revisit these.
47+
Most controllers eventually end up running on the cluster, so they need RBAC
48+
permissions, which we specify using controller-tools [RBAC
49+
markers](/reference/markers/rbac.md). These are the bare minimum permissions
50+
needed to run. As we add more functionality, we'll need to revisit these.
5051
*/
5152

5253
// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete

docs/book/src/cronjob-tutorial/testdata/emptymain.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ At this point, our main function is fairly simple:
5858
5959
- We set up some basic flags for metrics.
6060
61-
- We instantiate a [*manager*](../TODO.md), which keeps track of running all of
62-
our controllers, as well as setting up shared caches and clients to the API
63-
server (notice we tell the manager about our Scheme).
61+
- We instantiate a
62+
[*manager*](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/manager#Manager),
63+
which keeps track of running all of our controllers, as well as setting up
64+
shared caches and clients to the API server (notice we tell the manager about
65+
our Scheme).
6466
6567
- We run our manager, which in turn runs all of our controllers and webhooks.
6668
The manager is set up to run until it receives a graceful shutdown signal.

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func (r *CronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
5050

5151
/*
5252
Notice that we use kubebuilder markers to generate webhook manifests.
53-
This markers is responsible for generating a mutating webhook manifest.
53+
This marker is responsible for generating a mutating webhook manifest.
5454
55-
The meaning of each marker can be found [here](../TODO.md).
55+
The meaning of each marker can be found [here](/reference/markers/webhook.md).
5656
*/
5757

5858
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io
@@ -87,10 +87,7 @@ func (r *CronJob) Default() {
8787
}
8888

8989
/*
90-
Notice that we use kubebuilder markers to generate webhook manifests.
91-
This markers is responsible for generating a validating webhook manifest.
92-
93-
The meaning of each marker can be found [here](../TODO.md).
90+
This marker is responsible for generating a validating webhook manifest.
9491
*/
9592

9693
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=vcronjob.kb.io
@@ -156,7 +153,7 @@ You can find kubebuilder validation markers (prefixed
156153
with `// +kubebuilder:validation`) in the [API](api-design.md)
157154
You can find all of the kubebuilder supported markers for
158155
declaring validation by running `controller-gen crd -w`,
159-
or [here](../TODO.md).
156+
or [here](/reference/markers/crd-validation.md).
160157
*/
161158

162159
func (r *CronJob) validateCronJobSpec() *field.Error {

docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ func ignoreNotFound(err error) error {
8787

8888
/*
8989
Notice that we need a few more RBAC permissions -- since we're creating and
90-
managing jobs now, we'll need permissions for those.
90+
managing jobs now, we'll need permissions for those, which means adding
91+
a couple more [markers](/reference/markers/rbac.md).
9192
*/
9293

9394
// +kubebuilder:rbac:groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete

0 commit comments

Comments
 (0)