From 5092725ece297e77cf12875eaf2aad5892cf72c2 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Thu, 3 Jun 2021 21:31:06 +0000 Subject: [PATCH] Mark spec as required, status.atProvider as optional This is required to fix https://github.com/crossplane/provider-aws/issues/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 'requireness' to be more of a human-facing constraint than a software-facing constraint that our managed resource controllers should be subject to. Signed-off-by: Nic Cope --- templates/crossplane/apis/crd.go.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/crossplane/apis/crd.go.tpl b/templates/crossplane/apis/crd.go.tpl index a5803b32..bb45c04b 100644 --- a/templates/crossplane/apis/crd.go.tpl +++ b/templates/crossplane/apis/crd.go.tpl @@ -51,7 +51,7 @@ type {{ .CRD.Kind }}Observation struct { // {{ .CRD.Kind }}Status defines the observed state of {{ .CRD.Kind }}. type {{ .CRD.Kind }}Status struct { xpv1.ResourceStatus `json:",inline"` - AtProvider {{ .CRD.Kind }}Observation `json:"atProvider"` + AtProvider {{ .CRD.Kind }}Observation `json:"atProvider,omitempty"` } @@ -66,7 +66,7 @@ type {{ .CRD.Kind }}Status struct { type {{ .CRD.Kind }} struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec {{ .CRD.Kind }}Spec `json:"spec,omitempty"` + Spec {{ .CRD.Kind }}Spec `json:"spec"` Status {{ .CRD.Kind }}Status `json:"status,omitempty"` }