@@ -17,8 +17,6 @@ limitations under the License.
17
17
package routes
18
18
19
19
import (
20
- "strings"
21
-
22
20
restful "github.com/emicklei/go-restful"
23
21
"github.com/go-openapi/spec"
24
22
"k8s.io/klog/v2"
@@ -36,6 +34,17 @@ type OpenAPI struct {
36
34
37
35
// Install adds the SwaggerUI webservice to the given mux.
38
36
func (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" )
39
48
spec , err := builder .BuildOpenAPISpec (c .RegisteredWebServices (), oa .Config )
40
49
if err != nil {
41
50
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
46
55
klog .Fatalf ("Failed to create OpenAPIService: %v" , err )
47
56
}
48
57
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
-
61
58
err = openAPIVersionedService .RegisterOpenAPIVersionedService ("/openapi/v2" , mux )
62
59
if err != nil {
63
60
klog .Fatalf ("Failed to register versioned open api spec for root: %v" , err )
0 commit comments