Skip to content

Commit f2d7ee3

Browse files
committed
feat: enhance GuestbookEntry with required and optional markers
1 parent eb160e2 commit f2d7ee3

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

test/api/v1/guestbook_types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type PositiveInt int
124124
// GuestbookEntry defines an entry in a guest book.
125125
type GuestbookEntry struct {
126126
// Name of the guest (pipe | should be escaped)
127+
// +kubebuilder:validation:Required
127128
// +kubebuilder:validation:MaxLength=80
128129
// +kubebuilder:validation:Pattern=`0*[a-z0-9]*[a-z]*[0-9]`
129130
Name string `json:"name,omitempty"`
@@ -146,12 +147,19 @@ type GuestbookEntry struct {
146147
Comment string `json:"comment,omitempty"`
147148
// Rating provided by the guest
148149
Rating Rating `json:"rating,omitempty"`
150+
149151
// Email is the email address of the guest (required field using +required marker)
150152
// +required
151153
Email string `json:"email"`
152-
// Location is the location of the guest (required field using +kubebuilder:validation:Required marker)
153-
// +kubebuilder:validation:Required
154+
// Location is the location of the guest (required field using +k8s:required marker)
155+
// +k8s:required
154156
Location string `json:"location"`
157+
// Phone is the phone number of the guest (optional field using +optional marker)
158+
// +optional
159+
Phone string `json:"phone"`
160+
// Company is the company of the guest (optional field using +k8s:optional marker)
161+
// +k8s:optional
162+
Company string `json:"company"`
155163
}
156164

157165
// GuestbookStatus defines the observed state of Guestbook.

test/expected.asciidoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ GuestbookEntry defines an entry in a guest book.
162162
| Field | Description | Default | Validation
163163
| *`name`* __string__ | Name of the guest (pipe \| should be escaped) + | | MaxLength: 80 +
164164
Pattern: `0\*[a-z0-9]*[a-z]*[0-9]` +
165+
Required: \{} +
165166

166167
| *`tags`* __string array__ | Tags of the entry. + | | items:Pattern: `[a-z]*` +
167168

@@ -181,7 +182,11 @@ Minimum: 1 +
181182

182183
| *`email`* __string__ | Email is the email address of the guest (required field using +required marker) + | | Required: \{} +
183184

184-
| *`location`* __string__ | Location is the location of the guest (required field using +kubebuilder:validation:Required marker) + | | Required: \{} +
185+
| *`location`* __string__ | Location is the location of the guest (required field using +k8s:required marker) + | | Required: \{} +
186+
187+
| *`phone`* __string__ | Phone is the phone number of the guest (optional field using +optional marker) + | | Optional: \{} +
188+
189+
| *`company`* __string__ | Company is the company of the guest (optional field using +k8s:optional marker) + | | Optional: \{} +
185190

186191
|===
187192

test/expected.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,15 @@ _Appears in:_
127127

128128
| Field | Description | Default | Validation |
129129
| --- | --- | --- | --- |
130-
| `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80 <br />Pattern: `0*[a-z0-9]*[a-z]*[0-9]` <br /> |
130+
| `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80 <br />Pattern: `0*[a-z0-9]*[a-z]*[0-9]` <br />Required: \{\} <br /> |
131131
| `tags` _string array_ | Tags of the entry. | | items:Pattern: `[a-z]*` <br /> |
132132
| `time` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#time-v1-meta)_ | Time of entry | | |
133133
| `comment` _string_ | Comment by guest. This can be a multi-line comment.<br />Like this one.<br />Now let's test a list:<br />* a<br />* b<br />Another isolated comment.<br />Looks good? | | Pattern: `0*[a-z0-9]*[a-z]*[0-9]*\|\s` <br /> |
134134
| `rating` _[Rating](#rating)_ | Rating provided by the guest | | Maximum: 5 <br />Minimum: 1 <br /> |
135135
| `email` _string_ | Email is the email address of the guest (required field using +required marker) | | Required: \{\} <br /> |
136-
| `location` _string_ | Location is the location of the guest (required field using +kubebuilder:validation:Required marker) | | Required: \{\} <br /> |
136+
| `location` _string_ | Location is the location of the guest (required field using +k8s:required marker) | | Required: \{\} <br /> |
137+
| `phone` _string_ | Phone is the phone number of the guest (optional field using +optional marker) | | Optional: \{\} <br /> |
138+
| `company` _string_ | Company is the company of the guest (optional field using +k8s:optional marker) | | Optional: \{\} <br /> |
137139

138140

139141
#### GuestbookHeader

test/hide.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,15 @@ _Appears in:_
128128

129129
| Field | Description | Default | Validation |
130130
| --- | --- | --- | --- |
131-
| `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80 <br />Pattern: `0*[a-z0-9]*[a-z]*[0-9]` <br /> |
131+
| `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80 <br />Pattern: `0*[a-z0-9]*[a-z]*[0-9]` <br />Required: \{\} <br /> |
132132
| `tags` _string array_ | Tags of the entry. | | items:Pattern: `[a-z]*` <br /> |
133133
| `time` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#time-v1-meta)_ | Time of entry | | |
134134
| `comment` _string_ | Comment by guest. This can be a multi-line comment.<br />Like this one.<br />Now let's test a list:<br />* a<br />* b<br />Another isolated comment.<br />Looks good? | | Pattern: `0*[a-z0-9]*[a-z]*[0-9]*\|\s` <br /> |
135135
| `rating` _[Rating](#rating)_ | Rating provided by the guest | | Maximum: 5 <br />Minimum: 1 <br /> |
136+
| `email` _string_ | Email is the email address of the guest (required field using +required marker) | | Required: \{\} <br /> |
137+
| `location` _string_ | Location is the location of the guest (required field using +k8s:required marker) | | Required: \{\} <br /> |
138+
| `phone` _string_ | Phone is the phone number of the guest (optional field using +optional marker) | | Optional: \{\} <br /> |
139+
| `company` _string_ | Company is the company of the guest (optional field using +k8s:optional marker) | | Optional: \{\} <br /> |
136140

137141

138142
#### GuestbookHeader

0 commit comments

Comments
 (0)