func (v *etcdValidateHandler) Admit(ar *v1.AdmissionReview) *v1.AdmissionResponse {
	switch ar.Request.Operation {
	case v1.Create:
		var e etcdv1alpha1.EtcdCluster
		_, _, err := codecs.UniversalDeserializer().Decode(ar.Request.Object.Raw, nil, &e)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		if errs := validation.Validate(&e); len(errs) > 0 {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: errs.ToAggregate().Error()}}
		}
	case v1.Update:
		var newE, oldE etcdv1alpha1.EtcdCluster
		_, _, err := codecs.UniversalDeserializer().Decode(ar.Request.Object.Raw, nil, &newE)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		_, _, err = codecs.UniversalDeserializer().Decode(ar.Request.OldObject.Raw, nil, &oldE)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		if errs := validation.ValidateUpdate(&oldE, &newE); len(errs) > 0 {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: errs.ToAggregate().Error()}}
		}
	default:
	}
	return &v1.AdmissionResponse{Allowed: true}
}
// Admit validate the etcdculster's specification
Admit validate the etcdculster's specification
// Admit validate the etcdculster ' s specification
func (v *etcdValidateHandler) Admit(ar *v1.AdmissionReview) *v1.AdmissionResponse {
	switch ar.Request.Operation {
	case v1.Create:
		var e etcdv1alpha1.EtcdCluster
		_, _, err := codecs.UniversalDeserializer().Decode(ar.Request.Object.Raw, nil, &e)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		if errs := validation.Validate(&e); len(errs) > 0 {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: errs.ToAggregate().Error()}}
		}
	case v1.Update:
		var newE, oldE etcdv1alpha1.EtcdCluster
		_, _, err := codecs.UniversalDeserializer().Decode(ar.Request.Object.Raw, nil, &newE)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		_, _, err = codecs.UniversalDeserializer().Decode(ar.Request.OldObject.Raw, nil, &oldE)
		if err != nil {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: err.Error()}}
		}
		if errs := validation.ValidateUpdate(&oldE, &newE); len(errs) > 0 {
			return &v1.AdmissionResponse{Result: &metav1.Status{Message: errs.ToAggregate().Error()}}
		}
	default:
	}
	return &v1.AdmissionResponse{Allowed: true}
}
func ( v * etcdValidateHandler ) Admit ( ar * v1 . AdmissionReview ) * v1 . AdmissionResponse { switch ar . Request . Operation { case v1 . Create : var e etcdv1alpha1 . EtcdCluster _ , _ , err := codecs . UniversalDeserializer ( ) . Decode ( ar . Request . Object . Raw , nil , & e ) if err != nil { return & v1 . AdmissionResponse { Result : & metav1 . Status { Message : err . Error ( ) } } } if errs := validation . Validate ( & e ) ; len ( errs ) > 0 { return & v1 . AdmissionResponse { Result : & metav1 . Status { Message : errs . ToAggregate ( ) . Error ( ) } } } case v1 . Update : var newE , oldE etcdv1alpha1 . EtcdCluster _ , _ , err := codecs . UniversalDeserializer ( ) . Decode ( ar . Request . Object . Raw , nil , & newE ) if err != nil { return & v1 . AdmissionResponse { Result : & metav1 . Status { Message : err . Error ( ) } } } _ , _ , err = codecs . UniversalDeserializer ( ) . Decode ( ar . Request . OldObject . Raw , nil , & oldE ) if err != nil { return & v1 . AdmissionResponse { Result : & metav1 . Status { Message : err . Error ( ) } } } if errs := validation . ValidateUpdate ( & oldE , & newE ) ; len ( errs ) > 0 { return & v1 . AdmissionResponse { Result : & metav1 . Status { Message : errs . ToAggregate ( ) . Error ( ) } } } default : } return & v1 . AdmissionResponse { Allowed : true } }
Admit validate the etcdculster's specification
Admit validate the etcdculster ' s specification