-
Notifications
You must be signed in to change notification settings - Fork 447
✨ +enum
validation marker
#1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1bf22cb
b338e3f
bb6e2b6
ccd6c36
410a208
040149f
7aa3f6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,29 @@ import ( | |
|
||
const DefaultRefValue = "defaultRefValue" | ||
|
||
// +enum | ||
type EnumType string | ||
|
||
const ( | ||
EnumType_One EnumType = "one" | ||
EnumType_Two EnumType = "two" | ||
EnumType_Three EnumType = "three" | ||
) | ||
|
||
// This enum type tests for whether when both "+enum" and | ||
// "+kubebuilder:validation:Enum" are defined the latter takes precedence. | ||
// It should. | ||
// | ||
// +enum | ||
// +kubebuilder:validation:Enum=Allow;Forbid;Replace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about forbidding this behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would break users who have this already, for example on a type they don't actually control but have imported and then added the |
||
type AnotherEnumType string | ||
|
||
const ( | ||
AnotherEnumType_One AnotherEnumType = "another_one" | ||
AnotherEnumType_Two AnotherEnumType = "another_two" | ||
AnotherEnumType_Three AnotherEnumType = "another_three" | ||
) | ||
|
||
// CronJobSpec defines the desired state of CronJob | ||
// +kubebuilder:validation:XValidation:rule="has(oldSelf.forbiddenInt) || !has(self.forbiddenInt)",message="forbiddenInt is not allowed",fieldPath=".forbiddenInt",reason="FieldValueForbidden" | ||
type CronJobSpec struct { | ||
|
@@ -332,6 +355,11 @@ type CronJobSpec struct { | |
// +kubebuilder:validation:items:Enum=0;1;3 | ||
EnumSlice []int `json:"enumSlice,omitempty"` | ||
|
||
EnumValue EnumType `json:"enumValue,omitempty"` | ||
AnotherEnumValue AnotherEnumType `json:"anotherEnumValue,omitempty"` | ||
// +kubebuilder:validation:Enum=Allow;Forbid;Replace | ||
OneMoreEnumValue EnumType `json:"oneMoreEnumValue,omitempty"` | ||
|
||
HostsAlias Hosts `json:"hostsAlias,omitempty"` | ||
|
||
// This tests that alias imported from a package is handled correctly. The | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this last sentence.