Commit 94fcca3
committed
api: generate field ownership functions
Introduce a `protoc` generator (`tools/protoc-gen-owners`) to
automatically generate the repetitive field ownership tracking functions.
This refactors the `pkg/api/owners.go` file.
The new generator uses the `Field` enum in `api.proto` as the source of
truth. The original `owners.go` file has been split logically into
generated and handwritten parts:
- `owners_generated.go`: Contains the auto-generated boilerplate for
most fields.
- `owners.go`: Retains the core handwritten logic, including constructors,
conflict resolution, and special-cased handlers for fields with custom
logic (`OciHooks`, `Rdt`).
This change reduces manual boilerplate, improves maintainability, and ensures
consistency between the protobuf definitions and the Go API.
Assisted-by: gemini-cli
Signed-off-by: Samuel Karp <samuelkarp@google.com>1 parent 8c8e2be commit 94fcca3
4 files changed
Lines changed: 1206 additions & 635 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
| |||
0 commit comments