@@ -142,6 +142,9 @@ type crdInfo struct {
142
142
spec * apiextensionsv1.CustomResourceDefinitionSpec
143
143
acceptedNames * apiextensionsv1.CustomResourceDefinitionNames
144
144
145
+ // Deprecated per version
146
+ deprecated map [string ]bool
147
+
145
148
// Warnings per version
146
149
warnings map [string ][]string
147
150
@@ -329,10 +332,9 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
329
332
return
330
333
}
331
334
332
- if utilfeature .DefaultFeatureGate .Enabled (features .WarningHeaders ) {
333
- for _ , w := range crdInfo .warnings [requestInfo .APIVersion ] {
334
- warning .AddWarning (req .Context (), "" , w )
335
- }
335
+ deprecated := crdInfo .deprecated [requestInfo .APIVersion ]
336
+ for _ , w := range crdInfo .warnings [requestInfo .APIVersion ] {
337
+ warning .AddWarning (req .Context (), "" , w )
336
338
}
337
339
338
340
verb := strings .ToUpper (requestInfo .Verb )
@@ -372,7 +374,7 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
372
374
}
373
375
374
376
if handlerFunc != nil {
375
- handlerFunc = metrics .InstrumentHandlerFunc (verb , requestInfo .APIGroup , requestInfo .APIVersion , resource , subresource , scope , metrics .APIServerComponent , false , "" , handlerFunc )
377
+ handlerFunc = metrics .InstrumentHandlerFunc (verb , requestInfo .APIGroup , requestInfo .APIVersion , resource , subresource , scope , metrics .APIServerComponent , deprecated , "" , handlerFunc )
376
378
handler := genericfilters .WithWaitGroup (handlerFunc , longRunningFilter , crdInfo .waitGroup )
377
379
handler .ServeHTTP (w , req )
378
380
return
@@ -622,6 +624,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
622
624
storages := map [string ]customresource.CustomResourceStorage {}
623
625
statusScopes := map [string ]* handlers.RequestScope {}
624
626
scaleScopes := map [string ]* handlers.RequestScope {}
627
+ deprecated := map [string ]bool {}
625
628
warnings := map [string ][]string {}
626
629
627
630
equivalentResourceRegistry := runtime .NewEquivalentResourceRegistry ()
@@ -883,10 +886,13 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
883
886
statusScopes [v .Name ] = & statusScope
884
887
885
888
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 ))
889
+ deprecated [v .Name ] = true
890
+ if utilfeature .DefaultFeatureGate .Enabled (features .WarningHeaders ) {
891
+ if v .DeprecationWarning != nil {
892
+ warnings [v .Name ] = append (warnings [v .Name ], * v .DeprecationWarning )
893
+ } else {
894
+ warnings [v .Name ] = append (warnings [v .Name ], defaultDeprecationWarning (v .Name , crd .Spec ))
895
+ }
890
896
}
891
897
}
892
898
}
@@ -898,6 +904,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
898
904
requestScopes : requestScopes ,
899
905
scaleRequestScopes : scaleScopes ,
900
906
statusRequestScopes : statusScopes ,
907
+ deprecated : deprecated ,
901
908
warnings : warnings ,
902
909
storageVersion : storageVersion ,
903
910
waitGroup : & utilwaitgroup.SafeWaitGroup {},
0 commit comments