diff --git a/processor/processor.go b/processor/processor.go index 8bc4b79..b08dbbd 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -544,6 +544,8 @@ func parseMarkers(markers markers.MarkerValues) (string, []string) { name := strings.TrimPrefix(name, "kubebuilder:validation:") switch name { + case "items:Pattern": + fallthrough case "Pattern": value = fmt.Sprintf("`%s`", value) // FIXME: XValidation currently removed due to being long and difficult to read. diff --git a/test/api/v1/guestbook_types.go b/test/api/v1/guestbook_types.go index ff748c4..3fd6eba 100644 --- a/test/api/v1/guestbook_types.go +++ b/test/api/v1/guestbook_types.go @@ -124,6 +124,9 @@ type GuestbookEntry struct { // +kubebuilder:validation:MaxLength=80 // +kubebuilder:validation:Pattern=`0*[a-z0-9]*[a-z]*[0-9]` Name string `json:"name,omitempty"` + // Tags of the entry. + // +kubebuilder:validation:items:Pattern=`[a-z]*` + Tags []string `json:"tags"` // Time of entry Time metav1.Time `json:"time,omitempty"` // Comment by guest. This can be a multi-line comment. diff --git a/test/expected.asciidoc b/test/expected.asciidoc index cc160b4..89121ab 100644 --- a/test/expected.asciidoc +++ b/test/expected.asciidoc @@ -163,6 +163,8 @@ GuestbookEntry defines an entry in a guest book. | *`name`* __string__ | Name of the guest (pipe \| should be escaped) + | | MaxLength: 80 + Pattern: `0\*[a-z0-9]*[a-z]*[0-9]` + +| *`tags`* __string array__ | Tags of the entry. + | | items:Pattern: `[a-z]*` + + | *`time`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#time-v1-meta[$$Time$$]__ | Time of entry + | | | *`comment`* __string__ | Comment by guest. This can be a multi-line comment. + Like this one. + diff --git a/test/expected.md b/test/expected.md index b30d9f3..153d906 100644 --- a/test/expected.md +++ b/test/expected.md @@ -128,6 +128,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80
Pattern: `0*[a-z0-9]*[a-z]*[0-9]`
| +| `tags` _string array_ | Tags of the entry. | | items:Pattern: `[a-z]*`
| | `time` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#time-v1-meta)_ | Time of entry | | | | `comment` _string_ | Comment by guest. This can be a multi-line comment.
Like this one.
Now let's test a list:
* a
* b
Another isolated comment.
Looks good? | | Pattern: `0*[a-z0-9]*[a-z]*[0-9]*\|\s`
| | `rating` _[Rating](#rating)_ | Rating provided by the guest | | Maximum: 5
Minimum: 1
| diff --git a/test/hide.md b/test/hide.md index 4c63c30..668ca7a 100644 --- a/test/hide.md +++ b/test/hide.md @@ -127,6 +127,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `name` _string_ | Name of the guest (pipe \| should be escaped) | | MaxLength: 80
Pattern: `0*[a-z0-9]*[a-z]*[0-9]`
| +| `tags` _string array_ | Tags of the entry. | | items:Pattern: `[a-z]*`
| | `time` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#time-v1-meta)_ | Time of entry | | | | `comment` _string_ | Comment by guest. This can be a multi-line comment.
Like this one.
Now let's test a list:
* a
* b
Another isolated comment.
Looks good? | | Pattern: `0*[a-z0-9]*[a-z]*[0-9]*\|\s`
| | `rating` _[Rating](#rating)_ | Rating provided by the guest | | Maximum: 5
Minimum: 1
|