Skip to content

Commit 81374d8

Browse files
stttsbertinatto
authored andcommitted
UPSTREAM: <carry>: filter out CustomResourceQuota paths from OpenAPI
UPSTREAM: <carry>: filter out RBR and SCC paths from OpenAPI UPSTREAM: <carry>: filter out RBR and SCC paths from OpenAPI Revise as per openshift/kubernetes-apiserver#12 OpenShift-Rebase-Source: 26005f1
1 parent 81f4005 commit 81374d8

File tree

1 file changed

+27
-0
lines changed
  • staging/src/k8s.io/apiserver/pkg/server/routes

1 file changed

+27
-0
lines changed

staging/src/k8s.io/apiserver/pkg/server/routes/openapi.go

+27
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package routes
1818

1919
import (
20+
"strings"
21+
2022
restful "github.com/emicklei/go-restful/v3"
2123
"k8s.io/klog/v2"
2224

@@ -38,10 +40,35 @@ type OpenAPI struct {
3840

3941
// Install adds the SwaggerUI webservice to the given mux.
4042
func (oa OpenAPI) InstallV2(c *restful.Container, mux *mux.PathRecorderMux) (*handler.OpenAPIService, *spec.Swagger) {
43+
// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
44+
// with a CRD. This loop removes all CRQ,RBR, SCC paths
45+
// from the OpenAPI spec such that they don't conflict with the CRD
46+
// apiextensions-apiserver spec during merging.
47+
oa.Config.IgnorePrefixes = append(oa.Config.IgnorePrefixes,
48+
"/apis/quota.openshift.io/v1/clusterresourcequotas",
49+
"/apis/security.openshift.io/v1/securitycontextconstraints",
50+
"/apis/authorization.openshift.io/v1/rolebindingrestrictions",
51+
"/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindingrestrictions",
52+
"/apis/authorization.openshift.io/v1/watch/namespaces/{namespace}/rolebindingrestrictions",
53+
"/apis/authorization.openshift.io/v1/watch/rolebindingrestrictions")
54+
4155
spec, err := builder2.BuildOpenAPISpecFromRoutes(restfuladapter.AdaptWebServices(c.RegisteredWebServices()), oa.Config)
4256
if err != nil {
4357
klog.Fatalf("Failed to build open api spec for root: %v", err)
4458
}
59+
60+
// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
61+
// with a CRD. This loop removes all CRQ,RBR, SCC paths
62+
// from the OpenAPI spec such that they don't conflict with the CRD
63+
// apiextensions-apiserver spec during merging.
64+
for pth := range spec.Paths.Paths {
65+
if strings.HasPrefix(pth, "/apis/quota.openshift.io/v1/clusterresourcequotas") ||
66+
strings.Contains(pth, "rolebindingrestrictions") ||
67+
strings.HasPrefix(pth, "/apis/security.openshift.io/v1/securitycontextconstraints") {
68+
delete(spec.Paths.Paths, pth)
69+
}
70+
}
71+
4572
spec.Definitions = handler.PruneDefaults(spec.Definitions)
4673
openAPIVersionedService := handler.NewOpenAPIService(spec)
4774
openAPIVersionedService.RegisterOpenAPIVersionedService("/openapi/v2", mux)

0 commit comments

Comments
 (0)