func ValidateUpdate(oldE, newE *v1alpha1.EtcdCluster) field.ErrorList {
	allErrs := Validate(newE)
	if len(allErrs) > 0 {
		return allErrs
	}

	fldPath := field.NewPath("spec")

	oldV, _ := semver.Parse(oldE.Spec.Version)
	newV, _ := semver.Parse(newE.Spec.Version)
	if newV.LT(oldV) {
		allErrs = append(allErrs, field.Forbidden(fldPath.Child("version"), "version can't be downgrade"))
	}

	if !reflect.DeepEqual(oldE.Spec.Template.PersistentVolumeClaimSpec, newE.Spec.Template.PersistentVolumeClaimSpec) {
		allErrs = append(allErrs, field.Forbidden(fldPath.Child("template").Child("persistentVolumeClaimSpec"), "not allow updating now."))
	}

	if len(newE.Spec.Learners) > 0 {
		for _, member := range oldE.Status.Members {
			item := strings.Split(member.Name, "-")
			if item[len(item)-1] != newE.Spec.Learners[0] {
				continue
			}
			if member.Role == v1alpha1.EtcdMemberLeader || member.Role == v1alpha1.EtcdMemberFollower {
				allErrs = append(allErrs, field.Invalid(fldPath.Child("learners"), newE.Spec.Learners, "this node has already been a vote member"))
			}
		}
	}

	return allErrs
}
// ValidateUpdate validate if an etcd cluster updating is valid
ValidateUpdate validate if an etcd cluster updating is valid
// ValidateUpdate validate if an etcd cluster updating is valid
func ValidateUpdate(oldE, newE *v1alpha1.EtcdCluster) field.ErrorList {
	allErrs := Validate(newE)
	if len(allErrs) > 0 {
		return allErrs
	}
	fldPath := field.NewPath("spec")
	oldV, _ := semver.Parse(oldE.Spec.Version)
	newV, _ := semver.Parse(newE.Spec.Version)
	if newV.LT(oldV) {
		allErrs = append(allErrs, field.Forbidden(fldPath.Child("version"), "version can't be downgrade"))
	}
	if !reflect.DeepEqual(oldE.Spec.Template.PersistentVolumeClaimSpec, newE.Spec.Template.PersistentVolumeClaimSpec) {
		allErrs = append(allErrs, field.Forbidden(fldPath.Child("template").Child("persistentVolumeClaimSpec"), "not allow updating now."))
	}
	if len(newE.Spec.Learners) > 0 {
		for _, member := range oldE.Status.Members {
			item := strings.Split(member.Name, "-")
			if item[len(item)-1] != newE.Spec.Learners[0] {
				continue
			}
			if member.Role == v1alpha1.EtcdMemberLeader || member.Role == v1alpha1.EtcdMemberFollower {
				allErrs = append(allErrs, field.Invalid(fldPath.Child("learners"), newE.Spec.Learners, "this node has already been a vote member"))
			}
		}
	}
	return allErrs
}
func ValidateUpdate ( oldE , newE * v1alpha1 . EtcdCluster ) field . ErrorList { allErrs := Validate ( newE ) if len ( allErrs ) > 0 { return allErrs } fldPath := field . NewPath ( " " ) oldV , _ := semver . Parse ( oldE . Spec . Version ) newV , _ := semver . Parse ( newE . Spec . Version ) if newV . LT ( oldV ) { allErrs = append ( allErrs , field . Forbidden ( fldPath . Child ( " " ) , " " ) ) } if ! reflect . DeepEqual ( oldE . Spec . Template . PersistentVolumeClaimSpec , newE . Spec . Template . PersistentVolumeClaimSpec ) { allErrs = append ( allErrs , field . Forbidden ( fldPath . Child ( " " ) . Child ( " " ) , " " ) ) } if len ( newE . Spec . Learners ) > 0 { for _ , member := range oldE . Status . Members { item := strings . Split ( member . Name , " " ) if item [ len ( item ) - 1 ] != newE . Spec . Learners [ 0 ] { continue } if member . Role == v1alpha1 . EtcdMemberLeader || member . Role == v1alpha1 . EtcdMemberFollower { allErrs = append ( allErrs , field . Invalid ( fldPath . Child ( " " ) , newE . Spec . Learners , " " ) ) } } } return allErrs }
ValidateUpdate validate if an etcd cluster updating is valid
ValidateUpdate validate if an etcd cluster updating is valid