@@ -220,11 +220,7 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa
220
220
221
221
allErrs = append (allErrs , ValidateCrossVersionObjectReference (src .DescribedObject , fldPath .Child ("describedObject" ))... )
222
222
allErrs = append (allErrs , validateMetricIdentifier (src .Metric , fldPath .Child ("metric" ))... )
223
- if & src .Target == nil {
224
- allErrs = append (allErrs , field .Required (fldPath .Child ("target" ), "must specify a metric target" ))
225
- } else {
226
- allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
227
- }
223
+ allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
228
224
229
225
if src .Target .Value == nil && src .Target .AverageValue == nil {
230
226
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
237
233
allErrs := field.ErrorList {}
238
234
239
235
allErrs = append (allErrs , validateMetricIdentifier (src .Metric , fldPath .Child ("metric" ))... )
240
- if & src .Target == nil {
241
- allErrs = append (allErrs , field .Required (fldPath .Child ("target" ), "must specify a metric target" ))
242
- } else {
243
- allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
244
- }
236
+ allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
245
237
246
238
if src .Target .Value == nil && src .Target .AverageValue == nil {
247
239
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)
258
250
allErrs := field.ErrorList {}
259
251
260
252
allErrs = append (allErrs , validateMetricIdentifier (src .Metric , fldPath .Child ("metric" ))... )
261
- if & src .Target == nil {
262
- allErrs = append (allErrs , field .Required (fldPath .Child ("target" ), "must specify a metric target" ))
263
- } else {
264
- allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
265
- }
253
+ allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
266
254
267
255
if src .Target .AverageValue == nil {
268
256
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
277
265
if len (src .Name ) == 0 {
278
266
allErrs = append (allErrs , field .Required (fldPath .Child ("name" ), "must specify a resource name" ))
279
267
}
280
- if & src .Target == nil {
281
- allErrs = append (allErrs , field .Required (fldPath .Child ("target" ), "must specify a metric target" ))
282
- } else {
283
- allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
284
- }
268
+
269
+ allErrs = append (allErrs , validateMetricTarget (src .Target , fldPath .Child ("target" ))... )
285
270
286
271
if src .Target .AverageUtilization == nil && src .Target .AverageValue == nil {
287
272
allErrs = append (allErrs , field .Required (fldPath .Child ("target" ).Child ("averageUtilization" ), "must set either a target raw value or a target utilization" ))
0 commit comments