Skip to content

Commit c459288

Browse files
authored
crossplane: Mark spec as required, status.atProvider as optional (#81)
This is required to fix crossplane-contrib/provider-aws#697 In the vast majority of resources a spec is required, so I'd like to mark it as such. I believe that in the edge cases where the spec really contains only optional fields it's possible to write `spec: {}`. We prefer not to mark status fields as required, since resources will always exist at some point without their status and we consider 'requiredness' to be more of a human-facing constraint than a software-facing constraint that our managed resource controllers should be subject to. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 79fe5ae commit c459288

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

templates/crossplane/apis/crd.go.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type {{ .CRD.Kind }}Observation struct {
5151
// {{ .CRD.Kind }}Status defines the observed state of {{ .CRD.Kind }}.
5252
type {{ .CRD.Kind }}Status struct {
5353
xpv1.ResourceStatus `json:",inline"`
54-
AtProvider {{ .CRD.Kind }}Observation `json:"atProvider"`
54+
AtProvider {{ .CRD.Kind }}Observation `json:"atProvider,omitempty"`
5555
}
5656

5757

@@ -66,7 +66,7 @@ type {{ .CRD.Kind }}Status struct {
6666
type {{ .CRD.Kind }} struct {
6767
metav1.TypeMeta `json:",inline"`
6868
metav1.ObjectMeta `json:"metadata,omitempty"`
69-
Spec {{ .CRD.Kind }}Spec `json:"spec,omitempty"`
69+
Spec {{ .CRD.Kind }}Spec `json:"spec"`
7070
Status {{ .CRD.Kind }}Status `json:"status,omitempty"`
7171
}
7272

0 commit comments

Comments
 (0)