Skip to content

Commit d46b10e

Browse files
authored
Merge pull request #2529 from sayantani11/issue2520
📖Add info about markers
2 parents cf1575e + e9860e6 commit d46b10e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/book/src/reference/markers.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ a marker name, optionally followed by some marker specific configuration:
1515
// +kubebuilder:printcolumn:JSONPath=".status.replicas",name=Replicas,type=string
1616
```
1717

18+
<aside class="note">
19+
<h1>difference between `// +optional` and `// +kubebuilder:validation:Optional`</h1>
20+
21+
Controller-gen supports both (see the output of `controller-gen crd -www`). `+kubebuilder:validation:Optional` and `+optional` can be applied to fields.
22+
23+
But `+kubebuilder:validation:Optional` can also be applied at the package level such that it applies to every field in the package.
24+
25+
If you're using controller-gen only then they're redundant, but if you're using other generators or you want developers that need to build their own clients for your API, you'll want to also include `+optional`.
26+
27+
The most reliable way in 1.x to get `+optional` is `omitempty`.
28+
29+
</aside>
30+
1831
See each subsection for information about different types of code and YAML
1932
generation.
2033

0 commit comments

Comments
 (0)