Skip to content

Commit cf9a6ee

Browse files
authored
Merge pull request #4907 from camilamacedo86/go-kal
🐛 (go/v4): ensure that api scaffold are following k8s api conventions
2 parents 3074a10 + 9a0b86d commit cf9a6ee

File tree

68 files changed

+794
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+794
-374
lines changed

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import (
6262
the fields.
6363
*/
6464

65-
// CronJobSpec defines the desired state of CronJob.
65+
// CronJobSpec defines the desired state of CronJob
6666
type CronJobSpec struct {
6767
// +kubebuilder:validation:MinLength=0
6868

@@ -165,20 +165,28 @@ type CronJobStatus struct {
165165
// +kubebuilder:object:root=true
166166
// +kubebuilder:subresource:status
167167

168-
// CronJob is the Schema for the cronjobs API.
168+
// CronJob is the Schema for the cronjobs API
169169
type CronJob struct {
170170
/*
171171
*/
172-
metav1.TypeMeta `json:",inline"`
173-
metav1.ObjectMeta `json:"metadata,omitempty"`
172+
metav1.TypeMeta `json:",inline"`
173+
174+
// metadata is a standard object metadata
175+
// +optional
176+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
174177

175-
Spec CronJobSpec `json:"spec,omitempty"`
176-
Status CronJobStatus `json:"status,omitempty"`
178+
// spec defines the desired state of CronJob
179+
// +required
180+
Spec CronJobSpec `json:"spec"`
181+
182+
// status defines the observed state of CronJob
183+
// +optional
184+
Status CronJobStatus `json:"status,omitempty,omitzero"`
177185
}
178186

179187
// +kubebuilder:object:root=true
180188

181-
// CronJobList contains a list of CronJob.
189+
// CronJobList contains a list of CronJob
182190
type CronJobList struct {
183191
metav1.TypeMeta `json:",inline"`
184192
metav1.ListMeta `json:"metadata,omitempty"`

docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,8 @@ spec:
38403840
format: date-time
38413841
type: string
38423842
type: object
3843+
required:
3844+
- spec
38433845
type: object
38443846
served: true
38453847
storage: true

docs/book/src/cronjob-tutorial/testdata/project/dist/chart/templates/crd/batch.tutorial.kubebuilder.io_cronjobs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,6 +3846,8 @@ spec:
38463846
format: date-time
38473847
type: string
38483848
type: object
3849+
required:
3850+
- spec
38493851
type: object
38503852
served: true
38513853
storage: true

docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,6 +3848,8 @@ spec:
38483848
format: date-time
38493849
type: string
38503850
type: object
3851+
required:
3852+
- spec
38513853
type: object
38523854
served: true
38533855
storage: true

docs/book/src/getting-started/testdata/project/api/v1alpha1/memcached_types.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ import (
2626

2727
// +kubebuilder:docs-gen:collapse=Imports
2828

29-
// MemcachedSpec defines the desired state of Memcached.
29+
// MemcachedSpec defines the desired state of Memcached
3030
type MemcachedSpec struct {
3131
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3232
// Important: Run "make" to regenerate code after modifying this file
33+
// The following markers will use OpenAPI v3 schema to validate the value
34+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
3335

3436
// Size defines the number of Memcached instances
3537
// The following markers will use OpenAPI v3 schema to validate the value
@@ -62,18 +64,26 @@ type MemcachedStatus struct {
6264
// +kubebuilder:object:root=true
6365
// +kubebuilder:subresource:status
6466

65-
// Memcached is the Schema for the memcacheds API.
67+
// Memcached is the Schema for the memcacheds API
6668
type Memcached struct {
67-
metav1.TypeMeta `json:",inline"`
68-
metav1.ObjectMeta `json:"metadata,omitempty"`
69+
metav1.TypeMeta `json:",inline"`
70+
71+
// metadata is a standard object metadata
72+
// +optional
73+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
74+
75+
// spec defines the desired state of Memcached
76+
// +required
77+
Spec MemcachedSpec `json:"spec"`
6978

70-
Spec MemcachedSpec `json:"spec,omitempty"`
71-
Status MemcachedStatus `json:"status,omitempty"`
79+
// status defines the observed state of Memcached
80+
// +optional
81+
Status MemcachedStatus `json:"status,omitempty,omitzero"`
7282
}
7383

7484
// +kubebuilder:object:root=true
7585

76-
// MemcachedList contains a list of Memcached.
86+
// MemcachedList contains a list of Memcached
7787
type MemcachedList struct {
7888
metav1.TypeMeta `json:",inline"`
7989
metav1.ListMeta `json:"metadata,omitempty"`

docs/book/src/getting-started/testdata/project/config/crd/bases/cache.example.com_memcacheds.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: Memcached is the Schema for the memcacheds API.
20+
description: Memcached is the Schema for the memcacheds API
2121
properties:
2222
apiVersion:
2323
description: |-
@@ -37,7 +37,7 @@ spec:
3737
metadata:
3838
type: object
3939
spec:
40-
description: MemcachedSpec defines the desired state of Memcached.
40+
description: spec defines the desired state of Memcached
4141
properties:
4242
size:
4343
description: |-
@@ -50,7 +50,7 @@ spec:
5050
type: integer
5151
type: object
5252
status:
53-
description: MemcachedStatus defines the observed state of Memcached.
53+
description: status defines the observed state of Memcached
5454
properties:
5555
conditions:
5656
description: |-
@@ -122,6 +122,8 @@ spec:
122122
- type
123123
x-kubernetes-list-type: map
124124
type: object
125+
required:
126+
- spec
125127
type: object
126128
served: true
127129
storage: true

docs/book/src/getting-started/testdata/project/dist/chart/templates/crd/cache.example.com_memcacheds.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
- name: v1alpha1
2424
schema:
2525
openAPIV3Schema:
26-
description: Memcached is the Schema for the memcacheds API.
26+
description: Memcached is the Schema for the memcacheds API
2727
properties:
2828
apiVersion:
2929
description: |-
@@ -43,7 +43,7 @@ spec:
4343
metadata:
4444
type: object
4545
spec:
46-
description: MemcachedSpec defines the desired state of Memcached.
46+
description: spec defines the desired state of Memcached
4747
properties:
4848
size:
4949
description: |-
@@ -56,7 +56,7 @@ spec:
5656
type: integer
5757
type: object
5858
status:
59-
description: MemcachedStatus defines the observed state of Memcached.
59+
description: status defines the observed state of Memcached
6060
properties:
6161
conditions:
6262
description: |-
@@ -128,6 +128,8 @@ spec:
128128
- type
129129
x-kubernetes-list-type: map
130130
type: object
131+
required:
132+
- spec
131133
type: object
132134
served: true
133135
storage: true

docs/book/src/getting-started/testdata/project/dist/install.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
- name: v1alpha1
2626
schema:
2727
openAPIV3Schema:
28-
description: Memcached is the Schema for the memcacheds API.
28+
description: Memcached is the Schema for the memcacheds API
2929
properties:
3030
apiVersion:
3131
description: |-
@@ -45,7 +45,7 @@ spec:
4545
metadata:
4646
type: object
4747
spec:
48-
description: MemcachedSpec defines the desired state of Memcached.
48+
description: spec defines the desired state of Memcached
4949
properties:
5050
size:
5151
description: |-
@@ -58,7 +58,7 @@ spec:
5858
type: integer
5959
type: object
6060
status:
61-
description: MemcachedStatus defines the observed state of Memcached.
61+
description: status defines the observed state of Memcached
6262
properties:
6363
conditions:
6464
description: |-
@@ -130,6 +130,8 @@ spec:
130130
- type
131131
x-kubernetes-list-type: map
132132
type: object
133+
required:
134+
- spec
133135
type: object
134136
served: true
135137
storage: true

docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434

3535
// +kubebuilder:docs-gen:collapse=Imports
3636

37-
// CronJobSpec defines the desired state of CronJob.
37+
// CronJobSpec defines the desired state of CronJob
3838
type CronJobSpec struct {
3939
// +kubebuilder:validation:MinLength=0
4040

@@ -131,21 +131,29 @@ type CronJobStatus struct {
131131
// +kubebuilder:subresource:status
132132
// +versionName=v1
133133
// +kubebuilder:storageversion
134-
// CronJob is the Schema for the cronjobs API.
134+
// CronJob is the Schema for the cronjobs API
135135
type CronJob struct {
136-
metav1.TypeMeta `json:",inline"`
137-
metav1.ObjectMeta `json:"metadata,omitempty"`
136+
metav1.TypeMeta `json:",inline"`
137+
138+
// metadata is a standard object metadata
139+
// +optional
140+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
138141

139-
Spec CronJobSpec `json:"spec,omitempty"`
140-
Status CronJobStatus `json:"status,omitempty"`
142+
// spec defines the desired state of CronJob
143+
// +required
144+
Spec CronJobSpec `json:"spec"`
145+
146+
// status defines the observed state of CronJob
147+
// +optional
148+
Status CronJobStatus `json:"status,omitempty,omitzero"`
141149
}
142150

143151
/*
144152
*/
145153

146154
// +kubebuilder:object:root=true
147155

148-
// CronJobList contains a list of CronJob.
156+
// CronJobList contains a list of CronJob
149157
type CronJobList struct {
150158
metav1.TypeMeta `json:",inline"`
151159
metav1.ListMeta `json:"metadata,omitempty"`

docs/book/src/multiversion-tutorial/testdata/project/api/v2/cronjob_types.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
/*
4040
We'll leave our spec largely unchanged, except to change the schedule field to a new type.
4141
*/
42-
// CronJobSpec defines the desired state of CronJob.
42+
// CronJobSpec defines the desired state of CronJob
4343
type CronJobSpec struct {
4444
// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
4545
Schedule CronSchedule `json:"schedule"`
@@ -162,18 +162,26 @@ type CronJobStatus struct {
162162
// +kubebuilder:object:root=true
163163
// +kubebuilder:subresource:status
164164
// +versionName=v2
165-
// CronJob is the Schema for the cronjobs API.
165+
// CronJob is the Schema for the cronjobs API
166166
type CronJob struct {
167-
metav1.TypeMeta `json:",inline"`
168-
metav1.ObjectMeta `json:"metadata,omitempty"`
167+
metav1.TypeMeta `json:",inline"`
168+
169+
// metadata is a standard object metadata
170+
// +optional
171+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
169172

170-
Spec CronJobSpec `json:"spec,omitempty"`
171-
Status CronJobStatus `json:"status,omitempty"`
173+
// spec defines the desired state of CronJob
174+
// +required
175+
Spec CronJobSpec `json:"spec"`
176+
177+
// status defines the observed state of CronJob
178+
// +optional
179+
Status CronJobStatus `json:"status,omitempty,omitzero"`
172180
}
173181

174182
// +kubebuilder:object:root=true
175183

176-
// CronJobList contains a list of CronJob.
184+
// CronJobList contains a list of CronJob
177185
type CronJobList struct {
178186
metav1.TypeMeta `json:",inline"`
179187
metav1.ListMeta `json:"metadata,omitempty"`

0 commit comments

Comments
 (0)