diff --git a/pkg/apis/autoscaling/validation/validation.go b/pkg/apis/autoscaling/validation/validation.go index dcaa533ad2a..0ae5cfeed4f 100644 --- a/pkg/apis/autoscaling/validation/validation.go +++ b/pkg/apis/autoscaling/validation/validation.go @@ -220,11 +220,7 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.DescribedObject, fldPath.Child("describedObject"))...) allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...) - if &src.Target == nil { - allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target")) - } else { - allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) - } + allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) if src.Target.Value == nil && src.Target.AverageValue == nil { allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value or averageValue")) @@ -237,11 +233,7 @@ func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *fiel allErrs := field.ErrorList{} allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...) - if &src.Target == nil { - allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target")) - } else { - allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) - } + allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) if src.Target.Value == nil && src.Target.AverageValue == nil { allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value for metric or a per-pod target")) @@ -258,11 +250,7 @@ func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) allErrs := field.ErrorList{} allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...) - if &src.Target == nil { - allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target")) - } else { - allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) - } + allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) if src.Target.AverageValue == nil { allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must specify a positive target averageValue")) @@ -277,11 +265,8 @@ func validateResourceSource(src *autoscaling.ResourceMetricSource, fldPath *fiel if len(src.Name) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a resource name")) } - if &src.Target == nil { - allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target")) - } else { - allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) - } + + allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...) if src.Target.AverageUtilization == nil && src.Target.AverageValue == nil { allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageUtilization"), "must set either a target raw value or a target utilization")) diff --git a/pkg/apis/storage/validation/validation.go b/pkg/apis/storage/validation/validation.go index 2f3b438af27..b45fdea6c35 100644 --- a/pkg/apis/storage/validation/validation.go +++ b/pkg/apis/storage/validation/validation.go @@ -28,7 +28,6 @@ import ( api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/core/helper" apivalidation "k8s.io/kubernetes/pkg/apis/core/validation" - storagevalidation "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/apis/storage" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -187,7 +186,7 @@ func validateVolumeAttachmentSource(source *storage.VolumeAttachmentSource, fldP allErrs = append(allErrs, field.Required(fldPath.Child("persistentVolumeName"), "must specify non empty persistentVolumeName")) } case source.InlineVolumeSpec != nil: - allErrs = append(allErrs, storagevalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...) + allErrs = append(allErrs, apivalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...) } return allErrs }