@@ -71,13 +71,15 @@ func ValidateRolloutSpec(rollout *v1alpha1.Rollout, fldPath *field.Path) field.E
71
71
replicas := defaults .GetReplicasOrDefault (spec .Replicas )
72
72
allErrs = append (allErrs , apivalidation .ValidateNonnegativeField (int64 (replicas ), fldPath .Child ("replicas" ))... )
73
73
74
- if spec .Selector == nil {
75
- message := fmt .Sprintf (MissingFieldMessage , ".spec.selector" )
76
- allErrs = append (allErrs , field .Required (fldPath .Child ("selector" ), message ))
77
- } else {
78
- allErrs = append (allErrs , unversionedvalidation .ValidateLabelSelector (spec .Selector , fldPath .Child ("selector" ))... )
79
- if len (spec .Selector .MatchLabels )+ len (spec .Selector .MatchExpressions ) == 0 {
80
- allErrs = append (allErrs , field .Invalid (fldPath .Child ("selector" ), spec .Selector , "empty selector is invalid for deployment" ))
74
+ if spec .WorkloadRef == nil {
75
+ if spec .Selector == nil {
76
+ message := fmt .Sprintf (MissingFieldMessage , ".spec.selector" )
77
+ allErrs = append (allErrs , field .Required (fldPath .Child ("selector" ), message ))
78
+ } else {
79
+ allErrs = append (allErrs , unversionedvalidation .ValidateLabelSelector (spec .Selector , fldPath .Child ("selector" ))... )
80
+ if len (spec .Selector .MatchLabels )+ len (spec .Selector .MatchExpressions ) == 0 {
81
+ allErrs = append (allErrs , field .Invalid (fldPath .Child ("selector" ), spec .Selector , "empty selector is invalid for deployment" ))
82
+ }
81
83
}
82
84
}
83
85
@@ -119,9 +121,12 @@ func ValidateRolloutSpec(rollout *v1alpha1.Rollout, fldPath *field.Path) field.E
119
121
AllowMultipleHugePageResources : true ,
120
122
AllowDownwardAPIHugePages : true ,
121
123
}
122
- allErrs = append (allErrs , validation .ValidatePodTemplateSpecForReplicaSet (& template , selector , replicas , fldPath .Child ("template" ), opts )... )
123
- }
124
124
125
+ // Skip validating empty template for rollout resolved from ref
126
+ if rollout .Spec .TemplateResolvedFromRef || spec .WorkloadRef == nil {
127
+ allErrs = append (allErrs , validation .ValidatePodTemplateSpecForReplicaSet (& template , selector , replicas , fldPath .Child ("template" ), opts )... )
128
+ }
129
+ }
125
130
allErrs = append (allErrs , apivalidation .ValidateNonnegativeField (int64 (spec .MinReadySeconds ), fldPath .Child ("minReadySeconds" ))... )
126
131
127
132
revisionHistoryLimit := defaults .GetRevisionHistoryLimitOrDefault (rollout )
0 commit comments