@@ -749,39 +749,39 @@ func (*TestValidatorList) DeepCopyObject() runtime.Object { return nil }
749
749
750
750
var _ admission.Validator = & TestValidator {}
751
751
752
- func (v * TestValidator ) ValidateCreate () error {
752
+ func (v * TestValidator ) ValidateCreate () (admission. Warnings , error ) {
753
753
if v .Panic {
754
754
panic ("fake panic test" )
755
755
}
756
756
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" )
758
758
}
759
- return nil
759
+ return nil , nil
760
760
}
761
761
762
- func (v * TestValidator ) ValidateUpdate (old runtime.Object ) error {
762
+ func (v * TestValidator ) ValidateUpdate (old runtime.Object ) (admission. Warnings , error ) {
763
763
if v .Panic {
764
764
panic ("fake panic test" )
765
765
}
766
766
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" )
768
768
}
769
769
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 )
771
771
} 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 )
773
773
}
774
- return nil
774
+ return nil , nil
775
775
}
776
776
777
- func (v * TestValidator ) ValidateDelete () error {
777
+ func (v * TestValidator ) ValidateDelete () (admission. Warnings , error ) {
778
778
if v .Panic {
779
779
panic ("fake panic test" )
780
780
}
781
781
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" )
783
783
}
784
- return nil
784
+ return nil , nil
785
785
}
786
786
787
787
// TestDefaultValidator.
@@ -824,25 +824,25 @@ func (dv *TestDefaultValidator) Default() {
824
824
825
825
var _ admission.Validator = & TestDefaultValidator {}
826
826
827
- func (dv * TestDefaultValidator ) ValidateCreate () error {
827
+ func (dv * TestDefaultValidator ) ValidateCreate () (admission. Warnings , error ) {
828
828
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" )
830
830
}
831
- return nil
831
+ return nil , nil
832
832
}
833
833
834
- func (dv * TestDefaultValidator ) ValidateUpdate (old runtime.Object ) error {
834
+ func (dv * TestDefaultValidator ) ValidateUpdate (old runtime.Object ) (admission. Warnings , error ) {
835
835
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" )
837
837
}
838
- return nil
838
+ return nil , nil
839
839
}
840
840
841
- func (dv * TestDefaultValidator ) ValidateDelete () error {
841
+ func (dv * TestDefaultValidator ) ValidateDelete () (admission. Warnings , error ) {
842
842
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" )
844
844
}
845
- return nil
845
+ return nil , nil
846
846
}
847
847
848
848
// TestCustomDefaulter.
@@ -872,59 +872,59 @@ var _ admission.CustomDefaulter = &TestCustomDefaulter{}
872
872
873
873
type TestCustomValidator struct {}
874
874
875
- func (* TestCustomValidator ) ValidateCreate (ctx context.Context , obj runtime.Object ) error {
875
+ func (* TestCustomValidator ) ValidateCreate (ctx context.Context , obj runtime.Object ) (admission. Warnings , error ) {
876
876
logf .FromContext (ctx ).Info ("Validating object" )
877
877
req , err := admission .RequestFromContext (ctx )
878
878
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 )
880
880
}
881
881
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 )
883
883
}
884
884
885
885
v := obj .(* TestValidator ) //nolint:ifshort
886
886
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" )
888
888
}
889
- return nil
889
+ return nil , nil
890
890
}
891
891
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 ) {
893
893
logf .FromContext (ctx ).Info ("Validating object" )
894
894
req , err := admission .RequestFromContext (ctx )
895
895
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 )
897
897
}
898
898
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 )
900
900
}
901
901
902
902
v := newObj .(* TestValidator )
903
903
old := oldObj .(* TestValidator )
904
904
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" )
906
906
}
907
907
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 )
909
909
}
910
- return nil
910
+ return nil , nil
911
911
}
912
912
913
- func (* TestCustomValidator ) ValidateDelete (ctx context.Context , obj runtime.Object ) error {
913
+ func (* TestCustomValidator ) ValidateDelete (ctx context.Context , obj runtime.Object ) (admission. Warnings , error ) {
914
914
logf .FromContext (ctx ).Info ("Validating object" )
915
915
req , err := admission .RequestFromContext (ctx )
916
916
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 )
918
918
}
919
919
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 )
921
921
}
922
922
923
923
v := obj .(* TestValidator ) //nolint:ifshort
924
924
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" )
926
926
}
927
- return nil
927
+ return nil , nil
928
928
}
929
929
930
930
var _ admission.CustomValidator = & TestCustomValidator {}
0 commit comments