Move feature gate check to crdInfo construction time

This commit is contained in:
Jordan Liggitt 2020-07-06 14:29:18 -04:00
parent 205d5c5829
commit f03290c390

View File

@ -329,10 +329,8 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return return
} }
if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) { for _, w := range crdInfo.warnings[requestInfo.APIVersion] {
for _, w := range crdInfo.warnings[requestInfo.APIVersion] { warning.AddWarning(req.Context(), "", w)
warning.AddWarning(req.Context(), "", w)
}
} }
verb := strings.ToUpper(requestInfo.Verb) verb := strings.ToUpper(requestInfo.Verb)
@ -883,10 +881,12 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
statusScopes[v.Name] = &statusScope statusScopes[v.Name] = &statusScope
if v.Deprecated { if v.Deprecated {
if v.DeprecationWarning != nil { if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) {
warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning) if v.DeprecationWarning != nil {
} else { warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning)
warnings[v.Name] = append(warnings[v.Name], defaultDeprecationWarning(v.Name, crd.Spec)) } else {
warnings[v.Name] = append(warnings[v.Name], defaultDeprecationWarning(v.Name, crd.Spec))
}
} }
} }
} }