@@ -749,39 +749,39 @@ func (*TestValidatorList) DeepCopyObject() runtime.Object { return nil }
749749
750750var _ admission.Validator = & TestValidator {}
751751
752- func (v * TestValidator ) ValidateCreate () error {
752+ func (v * TestValidator ) ValidateCreate () (admission. Warnings , error ) {
753753 if v .Panic {
754754 panic ("fake panic test" )
755755 }
756756 if v .Replica < 0 {
757- return errors .New ("number of replica should be greater than or equal to 0" )
757+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
758758 }
759- return nil
759+ return nil , nil
760760}
761761
762- func (v * TestValidator ) ValidateUpdate (old runtime.Object ) error {
762+ func (v * TestValidator ) ValidateUpdate (old runtime.Object ) (admission. Warnings , error ) {
763763 if v .Panic {
764764 panic ("fake panic test" )
765765 }
766766 if v .Replica < 0 {
767- return errors .New ("number of replica should be greater than or equal to 0" )
767+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
768768 }
769769 if oldObj , ok := old .(* TestValidator ); ! ok {
770- return fmt .Errorf ("the old object is expected to be %T" , oldObj )
770+ return nil , fmt .Errorf ("the old object is expected to be %T" , oldObj )
771771 } else if v .Replica < oldObj .Replica {
772- return fmt .Errorf ("new replica %v should not be fewer than old replica %v" , v .Replica , oldObj .Replica )
772+ return nil , fmt .Errorf ("new replica %v should not be fewer than old replica %v" , v .Replica , oldObj .Replica )
773773 }
774- return nil
774+ return nil , nil
775775}
776776
777- func (v * TestValidator ) ValidateDelete () error {
777+ func (v * TestValidator ) ValidateDelete () (admission. Warnings , error ) {
778778 if v .Panic {
779779 panic ("fake panic test" )
780780 }
781781 if v .Replica > 0 {
782- return errors .New ("number of replica should be less than or equal to 0 to delete" )
782+ return nil , errors .New ("number of replica should be less than or equal to 0 to delete" )
783783 }
784- return nil
784+ return nil , nil
785785}
786786
787787// TestDefaultValidator.
@@ -824,25 +824,25 @@ func (dv *TestDefaultValidator) Default() {
824824
825825var _ admission.Validator = & TestDefaultValidator {}
826826
827- func (dv * TestDefaultValidator ) ValidateCreate () error {
827+ func (dv * TestDefaultValidator ) ValidateCreate () (admission. Warnings , error ) {
828828 if dv .Replica < 0 {
829- return errors .New ("number of replica should be greater than or equal to 0" )
829+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
830830 }
831- return nil
831+ return nil , nil
832832}
833833
834- func (dv * TestDefaultValidator ) ValidateUpdate (old runtime.Object ) error {
834+ func (dv * TestDefaultValidator ) ValidateUpdate (old runtime.Object ) (admission. Warnings , error ) {
835835 if dv .Replica < 0 {
836- return errors .New ("number of replica should be greater than or equal to 0" )
836+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
837837 }
838- return nil
838+ return nil , nil
839839}
840840
841- func (dv * TestDefaultValidator ) ValidateDelete () error {
841+ func (dv * TestDefaultValidator ) ValidateDelete () (admission. Warnings , error ) {
842842 if dv .Replica > 0 {
843- return errors .New ("number of replica should be less than or equal to 0 to delete" )
843+ return nil , errors .New ("number of replica should be less than or equal to 0 to delete" )
844844 }
845- return nil
845+ return nil , nil
846846}
847847
848848// TestCustomDefaulter.
@@ -872,59 +872,59 @@ var _ admission.CustomDefaulter = &TestCustomDefaulter{}
872872
873873type TestCustomValidator struct {}
874874
875- func (* TestCustomValidator ) ValidateCreate (ctx context.Context , obj runtime.Object ) error {
875+ func (* TestCustomValidator ) ValidateCreate (ctx context.Context , obj runtime.Object ) (admission. Warnings , error ) {
876876 logf .FromContext (ctx ).Info ("Validating object" )
877877 req , err := admission .RequestFromContext (ctx )
878878 if err != nil {
879- return fmt .Errorf ("expected admission.Request in ctx: %w" , err )
879+ return nil , fmt .Errorf ("expected admission.Request in ctx: %w" , err )
880880 }
881881 if req .Kind .Kind != testValidatorKind {
882- return fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
882+ return nil , fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
883883 }
884884
885885 v := obj .(* TestValidator ) //nolint:ifshort
886886 if v .Replica < 0 {
887- return errors .New ("number of replica should be greater than or equal to 0" )
887+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
888888 }
889- return nil
889+ return nil , nil
890890}
891891
892- func (* TestCustomValidator ) ValidateUpdate (ctx context.Context , oldObj , newObj runtime.Object ) error {
892+ func (* TestCustomValidator ) ValidateUpdate (ctx context.Context , oldObj , newObj runtime.Object ) (admission. Warnings , error ) {
893893 logf .FromContext (ctx ).Info ("Validating object" )
894894 req , err := admission .RequestFromContext (ctx )
895895 if err != nil {
896- return fmt .Errorf ("expected admission.Request in ctx: %w" , err )
896+ return nil , fmt .Errorf ("expected admission.Request in ctx: %w" , err )
897897 }
898898 if req .Kind .Kind != testValidatorKind {
899- return fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
899+ return nil , fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
900900 }
901901
902902 v := newObj .(* TestValidator )
903903 old := oldObj .(* TestValidator )
904904 if v .Replica < 0 {
905- return errors .New ("number of replica should be greater than or equal to 0" )
905+ return nil , errors .New ("number of replica should be greater than or equal to 0" )
906906 }
907907 if v .Replica < old .Replica {
908- return fmt .Errorf ("new replica %v should not be fewer than old replica %v" , v .Replica , old .Replica )
908+ return nil , fmt .Errorf ("new replica %v should not be fewer than old replica %v" , v .Replica , old .Replica )
909909 }
910- return nil
910+ return nil , nil
911911}
912912
913- func (* TestCustomValidator ) ValidateDelete (ctx context.Context , obj runtime.Object ) error {
913+ func (* TestCustomValidator ) ValidateDelete (ctx context.Context , obj runtime.Object ) (admission. Warnings , error ) {
914914 logf .FromContext (ctx ).Info ("Validating object" )
915915 req , err := admission .RequestFromContext (ctx )
916916 if err != nil {
917- return fmt .Errorf ("expected admission.Request in ctx: %w" , err )
917+ return nil , fmt .Errorf ("expected admission.Request in ctx: %w" , err )
918918 }
919919 if req .Kind .Kind != testValidatorKind {
920- return fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
920+ return nil , fmt .Errorf ("expected Kind TestValidator got %q" , req .Kind .Kind )
921921 }
922922
923923 v := obj .(* TestValidator ) //nolint:ifshort
924924 if v .Replica > 0 {
925- return errors .New ("number of replica should be less than or equal to 0 to delete" )
925+ return nil , errors .New ("number of replica should be less than or equal to 0 to delete" )
926926 }
927- return nil
927+ return nil , nil
928928}
929929
930930var _ admission.CustomValidator = & TestCustomValidator {}
0 commit comments