-
Notifications
You must be signed in to change notification settings - Fork 4
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
Adding validation for nfspvc(webhook and CRD validation) #12
Conversation
api/v1alpha1/nfspvc_webhook.go
Outdated
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
|
||
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. |
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.
remove this boilerplate
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.
Do the required changes and add tests to e2e about webhook
api/v1alpha1/nfspvc_webhook.go
Outdated
func (r *NfsPvc) ValidateCreate() (admission.Warnings, error) { | ||
nfspvclog.Info("validate create", "name", r.Name) | ||
|
||
// TODO(user): fill in your validation logic upon object creation. |
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.
remove this boilerplate
api/v1alpha1/nfspvc_webhook.go
Outdated
func (r *NfsPvc) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { | ||
nfspvclog.Info("validate update", "name", r.Name) | ||
|
||
// TODO(user): fill in your validation logic upon object update. |
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.
remove this boilerplate
api/v1alpha1/nfspvc_webhook.go
Outdated
func (r *NfsPvc) isRestrictedFieldUpdated(old *NfsPvc) (bool, string) { | ||
// modifying these fields is forbidden. | ||
if !reflect.DeepEqual(r.Spec.Server, old.Spec.Server) { | ||
return true, "server" | ||
} | ||
if !reflect.DeepEqual(r.Spec.Path, old.Spec.Path) { | ||
return true, "path" | ||
} | ||
if !reflect.DeepEqual(r.Spec.AccessModes, old.Spec.AccessModes) { | ||
return true, "access modes" | ||
} | ||
if !reflect.DeepEqual(r.Spec.Capacity, old.Spec.Capacity) { | ||
return true, "capacity" | ||
} | ||
return false, "" |
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.
String is returned but not used
api/v1alpha1/nfspvc_webhook.go
Outdated
corev1.ReadWriteOnce, | ||
corev1.ReadOnlyMany, | ||
corev1.ReadWriteMany, | ||
corev1.ReadWriteOncePod) |
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.
Think the end parenthesis needs to be in a newline? How does go fmt
handle it?
006776a
to
624e1a7
Compare
The CI here is failing, I think you need to pull from main following #14, rebase and commit |
624e1a7
to
126311a
Compare
Signed-off-by: omer5yerushalmi <omery2700@gmail.com>
126311a
to
869e05f
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mzeevi, omer5yerushalmi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.