Skip to content

Commit 1c4a7b4

Browse files
committed
Add pattern validator test
1 parent 83f6193 commit 1c4a7b4

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

pkg/crd/markers/zz_generated.markerhelp.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/crd/testdata/cronjob_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ type CronJobSpec struct {
105105
// This tests that object defaulting can be performed.
106106
// +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {bar: false}}}
107107
DefaultedObject []RootObject `json:"defaultedObject"`
108+
109+
// This tests that pattern validator is properly applied.
110+
// +kubebuilder:validation:Pattern=`^$|^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$`
111+
PatternObject string `json:"patternObject"`
108112
}
109113

110114
type NestedObject struct {

pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,6 +4788,10 @@ spec:
47884788
description: This flag is like suspend, but for when you really mean
47894789
it. It helps test the +kubebuilder:validation:Type marker.
47904790
type: string
4791+
patternObject:
4792+
description: This tests that pattern validator is properly applied.
4793+
pattern: ^$|^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$
4794+
type: string
47914795
schedule:
47924796
description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
47934797
type: string
@@ -4830,6 +4834,7 @@ spec:
48304834
- defaultedSlice
48314835
- defaultedString
48324836
- jobTemplate
4837+
- patternObject
48334838
- schedule
48344839
- twoOfAKindPart0
48354840
- twoOfAKindPart1

0 commit comments

Comments
 (0)