Skip to content

Commit

Permalink
Merge pull request #346 from soltysh/test_pattern
Browse files Browse the repository at this point in the history
🏃 Add pattern validator test
  • Loading branch information
k8s-ci-robot authored Oct 18, 2019
2 parents 7caf560 + 1c4a7b4 commit 674e40c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/crd/markers/zz_generated.markerhelp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/crd/testdata/cronjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ type CronJobSpec struct {
// This tests that object defaulting can be performed.
// +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {bar: false}}}
DefaultedObject []RootObject `json:"defaultedObject"`

// This tests that pattern validator is properly applied.
// +kubebuilder:validation:Pattern=`^$|^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$`
PatternObject string `json:"patternObject"`
}

type NestedObject struct {
Expand Down
5 changes: 5 additions & 0 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4788,6 +4788,10 @@ spec:
description: This flag is like suspend, but for when you really mean
it. It helps test the +kubebuilder:validation:Type marker.
type: string
patternObject:
description: This tests that pattern validator is properly applied.
pattern: ^$|^((https):\/\/?)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/?))$
type: string
schedule:
description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
type: string
Expand Down Expand Up @@ -4830,6 +4834,7 @@ spec:
- defaultedSlice
- defaultedString
- jobTemplate
- patternObject
- schedule
- twoOfAKindPart0
- twoOfAKindPart1
Expand Down

0 comments on commit 674e40c

Please sign in to comment.