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

chore: update all dependencies for the operator #685

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions api/v1alpha1/hostdevicenetwork_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -43,40 +44,40 @@ func (w *HostDeviceNetwork) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &HostDeviceNetwork{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (w *HostDeviceNetwork) ValidateCreate() error {
func (w *HostDeviceNetwork) ValidateCreate() (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

hostDeviceNetworkLog.Info("validate create", "name", w.Name)

return w.validateHostDeviceNetwork()
return nil, w.validateHostDeviceNetwork()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (w *HostDeviceNetwork) ValidateUpdate(_ runtime.Object) error {
func (w *HostDeviceNetwork) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

hostDeviceNetworkLog.Info("validate update", "name", w.Name)

return w.validateHostDeviceNetwork()
return nil, w.validateHostDeviceNetwork()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (w *HostDeviceNetwork) ValidateDelete() error {
func (w *HostDeviceNetwork) ValidateDelete() (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

hostDeviceNetworkLog.Info("validate delete", "name", w.Name)

// Validation for delete call is not required
return nil
return nil, nil
}

/*
Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha1/hostdevicenetwork_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var _ = Describe("Validate", func() {
ResourceName: "hostdev",
},
}
Expect(hostDeviceNetwork.ValidateCreate()).NotTo(HaveOccurred())
_, err := hostDeviceNetwork.ValidateCreate()
Expect(err).NotTo(HaveOccurred())
})
It("Invalid ResourceName", func() {
hostDeviceNetwork := HostDeviceNetwork{
Expand All @@ -40,7 +41,8 @@ var _ = Describe("Validate", func() {
ResourceName: "hostdev!!",
},
}
Expect(hostDeviceNetwork.ValidateCreate().Error()).To(ContainSubstring("Invalid Resource name"))
_, err := hostDeviceNetwork.ValidateCreate()
Expect(err.Error()).To(ContainSubstring("Invalid Resource name"))
})
})
})
19 changes: 10 additions & 9 deletions api/v1alpha1/nicclusterpolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

const (
Expand Down Expand Up @@ -62,38 +63,38 @@ func (w *NicClusterPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &NicClusterPolicy{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (w *NicClusterPolicy) ValidateCreate() error {
func (w *NicClusterPolicy) ValidateCreate() (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

nicClusterPolicyLog.Info("validate create", "name", w.Name)
return w.validateNicClusterPolicy()
return nil, w.validateNicClusterPolicy()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (w *NicClusterPolicy) ValidateUpdate(_ runtime.Object) error {
func (w *NicClusterPolicy) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

nicClusterPolicyLog.Info("validate update", "name", w.Name)
return w.validateNicClusterPolicy()
return nil, w.validateNicClusterPolicy()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (w *NicClusterPolicy) ValidateDelete() error {
func (w *NicClusterPolicy) ValidateDelete() (admission.Warnings, error) {
if skipValidations {
nicClusterPolicyLog.Info("skipping CR validation")
return nil
return nil, nil
}

nicClusterPolicyLog.Info("validate delete", "name", w.Name)

// Validation for delete call is not required
return nil
return nil, nil
}

/*
Expand Down
Loading
Loading