Skip to content

Commit

Permalink
rename validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeriy Khorunzhin committed Sep 5, 2024
1 parent 17cab25 commit 3cea0bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ import (
"github.com/deckhouse/virtualization/api/core/v1alpha2"
)

type LifeCycleValidator struct {
type SizingPoliciesValidator struct {
client client.Client
}

func NewLifeCycleValidator(client client.Client) *LifeCycleValidator {
return &LifeCycleValidator{client: client}
func NewSizingPoliciesValidator(client client.Client) *SizingPoliciesValidator {
return &SizingPoliciesValidator{client: client}
}

func (v *LifeCycleValidator) ValidateCreate(_ context.Context, vmclass *v1alpha2.VirtualMachineClass) (admission.Warnings, error) {
func (v *SizingPoliciesValidator) ValidateCreate(_ context.Context, vmclass *v1alpha2.VirtualMachineClass) (admission.Warnings, error) {
if hasCpuSizePoliciesCrosses(&vmclass.Spec) {
return nil, fmt.Errorf("vmclass %s has size policy cpu crosses", vmclass.Name)
}

return nil, nil
}

func (v *LifeCycleValidator) ValidateUpdate(_ context.Context, _, newVMClass *v1alpha2.VirtualMachineClass) (admission.Warnings, error) {
func (v *SizingPoliciesValidator) ValidateUpdate(_ context.Context, _, newVMClass *v1alpha2.VirtualMachineClass) (admission.Warnings, error) {
if hasCpuSizePoliciesCrosses(&newVMClass.Spec) {
return nil, fmt.Errorf("vmclass %s has size policy cpu crosses", newVMClass.Name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Validator struct {
func NewValidator(client client.Client, log *slog.Logger) *Validator {
return &Validator{
validators: []VirtualMachineClassValidator{
validators.NewLifeCycleValidator(client),
validators.NewSizingPoliciesValidator(client),
},
log: log.With("webhook", "validation"),
}
Expand Down

0 comments on commit 3cea0bd

Please sign in to comment.