Skip to content

Commit eea03f1

Browse files
stttsdamemi
authored andcommitted
UPSTREAM: <carry>: filter out CustomResourceQuota paths from OpenAPI
Origin-commit: b992ee2fcb5cd610e9242c3165908b6bc6e423f5 UPSTREAM: <carry>: filter out RBR and SCC paths from OpenAPI Origin-commit: 5ce9a77a641ec9d0399226af572e429317d3daf6 UPSTREAM: <carry>: filter out RBR and SCC paths from OpenAPI Origin-commit: 0ee08c7a5e138e8df2bd7d010e9ab59a6543cf63 Revise as per openshift/kubernetes-apiserver#12
1 parent 8758d05 commit eea03f1

File tree

1 file changed

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

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
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"
2123
"github.com/go-openapi/spec"
2224
"k8s.io/klog/v2"
@@ -34,11 +36,35 @@ type OpenAPI struct {
3436

3537
// Install adds the SwaggerUI webservice to the given mux.
3638
func (oa OpenAPI) Install(c *restful.Container, mux *mux.PathRecorderMux) (*handler.OpenAPIService, *spec.Swagger) {
39+
// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
40+
// with a CRD. This loop removes all CRQ,RBR, SCC paths
41+
// from the OpenAPI spec such that they don't conflict with the CRD
42+
// apiextensions-apiserver spec during merging.
43+
oa.Config.IgnorePrefixes = append(oa.Config.IgnorePrefixes,
44+
"/apis/quota.openshift.io/v1/clusterresourcequotas",
45+
"/apis/security.openshift.io/v1/securitycontextconstraints",
46+
"/apis/authorization.openshift.io/v1/rolebindingrestrictions",
47+
"/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindingrestrictions",
48+
"/apis/authorization.openshift.io/v1/watch/namespaces/{namespace}/rolebindingrestrictions",
49+
"/apis/authorization.openshift.io/v1/watch/rolebindingrestrictions")
50+
3751
spec, err := builder.BuildOpenAPISpec(c.RegisteredWebServices(), oa.Config)
3852
if err != nil {
3953
klog.Fatalf("Failed to build open api spec for root: %v", err)
4054
}
4155

56+
// we shadow ClustResourceQuotas, RoleBindingRestrictions, and SecurityContextContstraints
57+
// with a CRD. This loop removes all CRQ,RBR, SCC paths
58+
// from the OpenAPI spec such that they don't conflict with the CRD
59+
// apiextensions-apiserver spec during merging.
60+
for pth := range spec.Paths.Paths {
61+
if strings.HasPrefix(pth, "/apis/quota.openshift.io/v1/clusterresourcequotas") ||
62+
strings.Contains(pth, "rolebindingrestrictions") ||
63+
strings.HasPrefix(pth, "/apis/security.openshift.io/v1/securitycontextconstraints") {
64+
delete(spec.Paths.Paths, pth)
65+
}
66+
}
67+
4268
openAPIVersionedService, err := handler.NewOpenAPIService(spec)
4369
if err != nil {
4470
klog.Fatalf("Failed to create OpenAPIService: %v", err)

0 commit comments

Comments
 (0)