github.com/crossplane/upjet@v1.3.0/pkg/pipeline/templates/crd_types.go.tmpl (about)

     1  {{ .Header }}
     2  
     3  {{ .GenStatement }}
     4  
     5  package {{ .CRD.APIVersion }}
     6  
     7  import (
     8  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     9  	"k8s.io/apimachinery/pkg/runtime/schema"
    10  
    11  	{{ .Imports }}
    12  )
    13  
    14  {{ .Types }}
    15  
    16  // {{ .CRD.Kind }}Spec defines the desired state of {{ .CRD.Kind }}
    17  type {{ .CRD.Kind }}Spec struct {
    18  	{{ .XPCommonAPIsPackageAlias }}ResourceSpec `json:",inline"`
    19  	ForProvider       {{ .CRD.ForProviderType }} `json:"forProvider"`
    20  	// THIS IS A BETA FIELD. It will be honored
    21  	// unless the Management Policies feature flag is disabled.
    22  	// InitProvider holds the same fields as ForProvider, with the exception
    23  	// of Identifier and other resource reference fields. The fields that are
    24  	// in InitProvider are merged into ForProvider when the resource is created.
    25  	// The same fields are also added to the terraform ignore_changes hook, to
    26  	// avoid updating them after creation. This is useful for fields that are
    27  	// required on creation, but we do not desire to update them after creation,
    28  	// for example because of an external controller is managing them, like an
    29  	// autoscaler.
    30  	InitProvider       {{ .CRD.InitProviderType }} `json:"initProvider,omitempty"`
    31  }
    32  
    33  // {{ .CRD.Kind }}Status defines the observed state of {{ .CRD.Kind }}.
    34  type {{ .CRD.Kind }}Status struct {
    35  	{{ .XPCommonAPIsPackageAlias }}ResourceStatus `json:",inline"`
    36  	AtProvider          {{ .CRD.AtProviderType }} `json:"atProvider,omitempty"`
    37  }
    38  
    39  // +kubebuilder:object:root=true
    40  // +kubebuilder:subresource:status
    41  // +kubebuilder:storageversion
    42  
    43  // {{ .CRD.Kind }} is the Schema for the {{ .CRD.Kind }}s API. {{ .CRD.Description }}
    44  // +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
    45  // +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
    46  // +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name"
    47  // +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
    48  // +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,{{ .Provider.ShortName }}}{{ if .CRD.Path }},path={{ .CRD.Path }}{{ end }}
    49  type {{ .CRD.Kind }} struct {
    50  	metav1.TypeMeta   `json:",inline"`
    51  	metav1.ObjectMeta `json:"metadata,omitempty"`
    52  	{{- .CRD.ValidationRules }}
    53  	Spec              {{ .CRD.Kind }}Spec   `json:"spec"`
    54  	Status            {{ .CRD.Kind }}Status `json:"status,omitempty"`
    55  }
    56  
    57  // +kubebuilder:object:root=true
    58  
    59  // {{ .CRD.Kind }}List contains a list of {{ .CRD.Kind }}s
    60  type {{ .CRD.Kind }}List struct {
    61  	metav1.TypeMeta `json:",inline"`
    62  	metav1.ListMeta `json:"metadata,omitempty"`
    63  	Items           []{{ .CRD.Kind }} `json:"items"`
    64  }
    65  
    66  // Repository type metadata.
    67  var (
    68  	{{ .CRD.Kind }}_Kind             = "{{ .CRD.Kind }}"
    69  	{{ .CRD.Kind }}_GroupKind        = schema.GroupKind{Group: CRDGroup, Kind: {{ .CRD.Kind }}_Kind}.String()
    70  	{{ .CRD.Kind }}_KindAPIVersion   = {{ .CRD.Kind }}_Kind + "." + CRDGroupVersion.String()
    71  	{{ .CRD.Kind }}_GroupVersionKind = CRDGroupVersion.WithKind({{ .CRD.Kind }}_Kind)
    72  )
    73  
    74  func init() {
    75  	SchemeBuilder.Register(&{{ .CRD.Kind }}{}, &{{ .CRD.Kind }}List{})
    76  }