Ensure that watches use the latest schemas

This commit is contained in:
Darren Shepherd 2021-08-10 11:03:59 -07:00
parent 0414d4acf5
commit 426330efa2

View File

@ -19,13 +19,23 @@ import (
steveschema "github.com/rancher/steve/pkg/schema"
"github.com/rancher/steve/pkg/stores/proxy"
"github.com/rancher/steve/pkg/summarycache"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/client-go/discovery"
)
func DefaultSchemas(ctx context.Context, baseSchema *types.APISchemas, ccache clustercache.ClusterCache,
cg proxy.ClientGetter, schemaFactory steveschema.Factory) error {
counts.Register(baseSchema, ccache)
subscribe.Register(baseSchema)
subscribe.Register(baseSchema, func(apiOp *types.APIRequest) *types.APISchemas {
user, ok := request.UserFrom(apiOp.Context())
if ok {
schemas, err := schemaFactory.Schemas(user)
if err == nil {
return schemas
}
}
return apiOp.Schemas
})
apiroot.Register(baseSchema, []string{"v1"}, "proxy:/apis")
cluster.Register(ctx, baseSchema, cg, schemaFactory)
userpreferences.Register(baseSchema)