Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,19 @@ func (v *Validator) ValidateCreate(ctx context.Context, obj runtime.Object) (adm
return nil, fmt.Errorf("the VirtualMachineIPAddress validation is failed: %w", err)
}

var warnings admission.Warnings

if vmip.Spec.StaticIP != "" {
err = v.validateAllocatedIPAddresses(ctx, vmip.Spec.StaticIP)
switch {
case err == nil:
// OK.
case errors.Is(err, service.ErrIPAddressOutOfRange):
warnings = append(warnings, fmt.Sprintf("The requested address %s is out of the valid range", vmip.Spec.StaticIP))
return nil, fmt.Errorf("the requested address %s is out of the valid range", vmip.Spec.StaticIP)
default:
return nil, err
}
}

return warnings, nil
return nil, nil
}

func (v *Validator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
Expand Down
Loading