Skip to content

Commit 5c76eac

Browse files
committed
Document the controller scaffolding
1 parent 14779ab commit 5c76eac

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

cmd/scaffold-controller/main.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ import (
1919
"golang.org/x/text/language"
2020
)
2121

22-
// TODO:
23-
// - generate bundle manifest with make (it requires installing openshift-sdk, wich would need to be installed on every CI run. Perhaps not worth it.)
24-
// - Documentation
25-
26-
// Then, one needs to:
27-
// Add to `cmd/resource-generator/main.go` and run `make generate`
28-
// Add the new client to `internal/scope/scope.go`
29-
// Add to `cmd/manager/main.go`
30-
// Implement TODOs
31-
// Run the tests
32-
// Update README
33-
3422
//go:embed data
3523
var data embed.FS
3624

website/docs/development/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
# Developing controllers
22

33
This documentation goes over the different steps needed to write a new controller from scratch.
4+
5+
## Using the controller scaffolding generator
6+
7+
ORC comes with a controller scaffolding tool that does most of the heavy work when writing a new controller.
8+
It asks a series of questions, then generates stubs for the API, controller implementation, tests and client code.
9+
10+
To run the scaffolding tool:
11+
```bash
12+
$ go run ./cmd/scaffold-controller
13+
```
14+
15+
The tool can be run either interactively, if you don't pass it any option, or non-interactively if you pass it the `-interactive=false` flag and provide all of the required flags.
16+
17+
Once the tool returned successfully, there are still a few manual steps to integrate your new controller in ORC:
18+
19+
* Add the new resource to `cmd/resource-generator/main.go` and run `make generate`.
20+
* Add the new client to `internal/scope/scope.go`, `internal/scope/provider.go`, and `internal/scope/mock.go`.
21+
* Add the controller to `cmd/manager/main.go`.
22+
* Implement all the TODOs. Search the code for `TODO(scaffolding)` to find them all.
23+
* Iterate on your controller and get all the tests running.
24+
* Run `make generate-bundle` to generate the OLM bundle manifests.
25+
* Update the `README.md` file to list the new controller.
26+
27+
The following pages go into the details for writing controllers.

0 commit comments

Comments
 (0)