Skip to content

Commit d415f93

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 56a428f commit d415f93

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

Lines changed: 27 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
"k8s.io/klog/v2"
2224

@@ -36,10 +38,35 @@ type OpenAPI struct {
3638

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

0 commit comments

Comments
 (0)