Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions pkg/server/routes/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package routes

import (
"strings"

restful "github.com/emicklei/go-restful"
"github.com/go-openapi/spec"
"k8s.io/klog/v2"
Expand All @@ -36,6 +34,17 @@ type OpenAPI struct {

// Install adds the SwaggerUI webservice to the given mux.
func (oa OpenAPI) Install(c *restful.Container, mux *mux.PathRecorderMux) (*handler.OpenAPIService, *spec.Swagger) {
// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
// with a CRD. This loop removes all CRQ,RBR, SCC paths
// from the OpenAPI spec such that they don't conflict with the CRD
// apiextensions-apiserver spec during merging.
oa.Config.IgnorePrefixes = append(oa.Config.IgnorePrefixes,
"/apis/quota.openshift.io/v1/clusterresourcequotas",
"/apis/security.openshift.io/v1/securitycontextconstraints",
"/apis/authorization.openshift.io/v1/rolebindingrestrictions",
"/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindingrestrictions",
"/apis/authorization.openshift.io/v1/watch/namespaces/{namespace}/rolebindingrestrictions",
"/apis/authorization.openshift.io/v1/watch/rolebindingrestrictions")
spec, err := builder.BuildOpenAPISpec(c.RegisteredWebServices(), oa.Config)
if err != nil {
klog.Fatalf("Failed to build open api spec for root: %v", err)
Expand All @@ -46,18 +55,6 @@ func (oa OpenAPI) Install(c *restful.Container, mux *mux.PathRecorderMux) (*hand
klog.Fatalf("Failed to create OpenAPIService: %v", err)
}

// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
// with a CRD. This loop removes all CRQ,RBR, SCC paths
// from the OpenAPI spec such that they don't conflict with the CRD
// apiextensions-apiserver spec during merging.
for pth := range spec.Paths.Paths {
if strings.HasPrefix(pth, "/apis/quota.openshift.io/v1/clusterresourcequotas") ||
strings.Contains(pth, "rolebindingrestrictions") ||
strings.HasPrefix(pth, "/apis/security.openshift.io/v1/securitycontextconstraints") {
delete(spec.Paths.Paths, pth)
}
}

err = openAPIVersionedService.RegisterOpenAPIVersionedService("/openapi/v2", mux)
if err != nil {
klog.Fatalf("Failed to register versioned open api spec for root: %v", err)
Expand Down