Skip to content

Commit f03290c

Browse files
committed
Move feature gate check to crdInfo construction time
1 parent 205d5c5 commit f03290c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,8 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
329329
return
330330
}
331331

332-
if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) {
333-
for _, w := range crdInfo.warnings[requestInfo.APIVersion] {
334-
warning.AddWarning(req.Context(), "", w)
335-
}
332+
for _, w := range crdInfo.warnings[requestInfo.APIVersion] {
333+
warning.AddWarning(req.Context(), "", w)
336334
}
337335

338336
verb := strings.ToUpper(requestInfo.Verb)
@@ -883,10 +881,12 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
883881
statusScopes[v.Name] = &statusScope
884882

885883
if v.Deprecated {
886-
if v.DeprecationWarning != nil {
887-
warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning)
888-
} else {
889-
warnings[v.Name] = append(warnings[v.Name], defaultDeprecationWarning(v.Name, crd.Spec))
884+
if utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders) {
885+
if v.DeprecationWarning != nil {
886+
warnings[v.Name] = append(warnings[v.Name], *v.DeprecationWarning)
887+
} else {
888+
warnings[v.Name] = append(warnings[v.Name], defaultDeprecationWarning(v.Name, crd.Spec))
889+
}
890890
}
891891
}
892892
}

0 commit comments

Comments
 (0)