@@ -17,8 +17,6 @@ limitations under the License.
1717package routes
1818
1919import (
20- "strings"
21-
2220 restful "github.com/emicklei/go-restful"
2321 "github.com/go-openapi/spec"
2422 "k8s.io/klog/v2"
@@ -36,6 +34,17 @@ type OpenAPI struct {
3634
3735// Install adds the SwaggerUI webservice to the given mux.
3836func (oa OpenAPI ) Install (c * restful.Container , mux * mux.PathRecorderMux ) (* handler.OpenAPIService , * spec.Swagger ) {
37+ // we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
38+ // with a CRD. This loop removes all CRQ,RBR, SCC paths
39+ // from the OpenAPI spec such that they don't conflict with the CRD
40+ // apiextensions-apiserver spec during merging.
41+ oa .Config .IgnorePrefixes = append (oa .Config .IgnorePrefixes ,
42+ "/apis/quota.openshift.io/v1/clusterresourcequotas" ,
43+ "/apis/security.openshift.io/v1/securitycontextconstraints" ,
44+ "/apis/authorization.openshift.io/v1/rolebindingrestrictions" ,
45+ "/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindingrestrictions" ,
46+ "/apis/authorization.openshift.io/v1/watch/namespaces/{namespace}/rolebindingrestrictions" ,
47+ "/apis/authorization.openshift.io/v1/watch/rolebindingrestrictions" )
3948 spec , err := builder .BuildOpenAPISpec (c .RegisteredWebServices (), oa .Config )
4049 if err != nil {
4150 klog .Fatalf ("Failed to build open api spec for root: %v" , err )
@@ -46,18 +55,6 @@ func (oa OpenAPI) Install(c *restful.Container, mux *mux.PathRecorderMux) (*hand
4655 klog .Fatalf ("Failed to create OpenAPIService: %v" , err )
4756 }
4857
49- // we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
50- // with a CRD. This loop removes all CRQ,RBR, SCC paths
51- // from the OpenAPI spec such that they don't conflict with the CRD
52- // apiextensions-apiserver spec during merging.
53- for pth := range spec .Paths .Paths {
54- if strings .HasPrefix (pth , "/apis/quota.openshift.io/v1/clusterresourcequotas" ) ||
55- strings .Contains (pth , "rolebindingrestrictions" ) ||
56- strings .HasPrefix (pth , "/apis/security.openshift.io/v1/securitycontextconstraints" ) {
57- delete (spec .Paths .Paths , pth )
58- }
59- }
60-
6158 err = openAPIVersionedService .RegisterOpenAPIVersionedService ("/openapi/v2" , mux )
6259 if err != nil {
6360 klog .Fatalf ("Failed to register versioned open api spec for root: %v" , err )
0 commit comments