Skip to content
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

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

omer5yerushalmi
Copy link
Contributor

No description provided.

Comment on lines 60 to 62
// 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this boilerplate

Copy link
Contributor

@mzeevi mzeevi left a 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

func (r *NfsPvc) ValidateCreate() (admission.Warnings, error) {
nfspvclog.Info("validate create", "name", r.Name)

// TODO(user): fill in your validation logic upon object creation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this boilerplate

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this boilerplate

Comment on lines 103 to 117
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, ""
Copy link
Contributor

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

corev1.ReadWriteOnce,
corev1.ReadOnlyMany,
corev1.ReadWriteMany,
corev1.ReadWriteOncePod)
Copy link
Contributor

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?

@mzeevi
Copy link
Contributor

mzeevi commented Dec 25, 2023

The CI here is failing, I think you need to pull from main following #14, rebase and commit

Signed-off-by: omer5yerushalmi <omery2700@gmail.com>
@mzeevi
Copy link
Contributor

mzeevi commented Dec 26, 2023

/lgtm
/approve

Copy link
Contributor

dana-prow-ci bot commented Dec 26, 2023

[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:
  • OWNERS [mzeevi,omer5yerushalmi]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dana-prow-ci dana-prow-ci bot merged commit 24d46f6 into main Dec 26, 2023
2 checks passed
@dana-prow-ci dana-prow-ci bot deleted the nfspvc-validation branch December 26, 2023 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants