-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add cluster size validation rule #230
Conversation
api/v1alpha1/nats_types.go
Outdated
@@ -125,6 +125,7 @@ type Cluster struct { | |||
// +kubebuilder:default:=3 | |||
// +kubebuilder:validation:Minimum:=1 | |||
// +kubebuilder:validation:XValidation:rule="(self%2) != 0", message="size only accepts odd numbers" | |||
// +kubebuilder:validation:XValidation:rule="!(oldSelf > 1 && self == 1)", message="size cannot be reduced to 1 once it was >1" |
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.
message="size cannot be reduced to 1 once it was >1"
Wasn't this the other way around? Once it will be set to 1
it cannot be changed?
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.
No, the rule is, once it was set to greater than 1
it can never be 1
again. I can try to make the message clearer like cannot be set to 1 if size was greater than 1
?
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.
Okay, looks I got that wrong. Nevermind then.
@@ -267,6 +267,36 @@ func Test_Validate_UpdateNATS(t *testing.T) { | |||
}, | |||
wantErrMsg: "fileStorage is immutable once it was set", | |||
}, | |||
{ | |||
name: `validation of cluster fails, if cluster.size>1 gets set to 1'`, |
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.
This sentence is a little confusing. How about:
name: `validation of cluster fails, if cluster.size>1 gets set to 1'`, | |
name: `validation of cluster fails, if cluster.size was set to a value >1 and now gets changed to 1'`, |
...or something similar.
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.
Done!
Description
Changes proposed in this pull request:
Validation rule:
Related issue(s)
#210