Skip to content

webhook: add webhooks for volumereplication#271

Merged
mergify[bot] merged 1 commit into
csi-addons:mainfrom
Madhu-1:add-webhook-vr
Nov 15, 2022
Merged

webhook: add webhooks for volumereplication#271
mergify[bot] merged 1 commit into
csi-addons:mainfrom
Madhu-1:add-webhook-vr

Conversation

@Madhu-1

@Madhu-1 Madhu-1 commented Nov 15, 2022

Copy link
Copy Markdown
Member

Add webhook for volume replication object to prevent users from changing the dataSource or the volumeReplicationClass once created. Below is the command to generate a webhook for VolumeReplication object

$ operator-sdk create webhook --group replication.storage --version v1alpha1 --kind VolumeReplication --programmatic-validation

Signed-off-by: Madhu Rajanna madhupr007@gmail.com

Rakshith-R
Rakshith-R previously approved these changes Nov 15, 2022
@Madhu-1 Madhu-1 requested a review from Rakshith-R November 15, 2022 10:29
@mergify mergify Bot dismissed Rakshith-R’s stale review November 15, 2022 10:29

Pull request has been modified.

@Madhu-1

Madhu-1 commented Nov 15, 2022

Copy link
Copy Markdown
Member Author

Fixed linter error.

Rakshith-R
Rakshith-R previously approved these changes Nov 15, 2022
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("volumeReplicationClass"), v.Spec.VolumeReplicationClass, "volumeReplicationClass cannot be changed"))
}

if len(allErrs) == 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally invert the logic? If there are no errors, the last return of the function returns nil, any errors in between return early from the function.

Add webhook for volume replication object to
avoid users from changing the dataSource or
the volumeReplicationClass once created.
Below is the command to generate webhook for
VolumeReplication object

```bash
$ operator-sdk create webhook --group replication.storage
--version v1alpha1 --kind VolumeReplication
--programmatic-validation
```

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
@mergify mergify Bot dismissed Rakshith-R’s stale review November 15, 2022 11:54

Pull request has been modified.

@mergify mergify Bot merged commit 7682427 into csi-addons:main Nov 15, 2022
Nikhil-Ladha pushed a commit to Nikhil-Ladha/kubernetes-csi-addons that referenced this pull request Apr 3, 2025
Syncing latest changes from upstream main for kubernetes-csi-addons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants