mirror of
https://github.com/niusmallnan/steve.git
synced 2025-08-31 12:48:54 +00:00
Rename to RESTConfig
This commit is contained in:
@@ -49,7 +49,7 @@ func (c *Config) ToServer(ctx context.Context) (*server.Server, error) {
|
||||
}
|
||||
|
||||
return &server.Server{
|
||||
RestConfig: restConfig,
|
||||
RESTConfig: restConfig,
|
||||
AuthMiddleware: auth,
|
||||
DashboardURL: func() string {
|
||||
return c.DashboardURL
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/rancher/steve/pkg/accesscontrol"
|
||||
"github.com/rancher/steve/pkg/auth"
|
||||
"github.com/rancher/steve/pkg/client"
|
||||
"github.com/rancher/steve/pkg/clustercache"
|
||||
"github.com/rancher/steve/pkg/schema"
|
||||
"github.com/rancher/steve/pkg/server/router"
|
||||
"github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
|
||||
@@ -29,7 +30,7 @@ import (
|
||||
type Server struct {
|
||||
*Controllers
|
||||
|
||||
RestConfig *rest.Config
|
||||
RESTConfig *rest.Config
|
||||
|
||||
ClientFactory *client.Factory
|
||||
BaseSchemas *types.APISchemas
|
||||
@@ -38,13 +39,14 @@ type Server struct {
|
||||
AuthMiddleware auth.Middleware
|
||||
Next http.Handler
|
||||
Router router.RouterFunc
|
||||
ClusterCache clustercache.ClusterCache
|
||||
PostStartHooks []func() error
|
||||
StartHooks []StartHook
|
||||
DashboardURL func() string
|
||||
}
|
||||
|
||||
type Controllers struct {
|
||||
RestConfig *rest.Config
|
||||
RESTConfig *rest.Config
|
||||
K8s kubernetes.Interface
|
||||
Core corev1.Interface
|
||||
RBAC rbacv1.Interface
|
||||
@@ -100,7 +102,7 @@ func NewController(cfg *rest.Config, opts *generic.FactoryOptions) (*Controllers
|
||||
c.RBAC = rbac.Rbac().V1()
|
||||
c.API = api.Apiregistration().V1()
|
||||
c.CRD = crd.Apiextensions().V1beta1()
|
||||
c.RestConfig = cfg
|
||||
c.RESTConfig = cfg
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
@@ -23,13 +23,13 @@ import (
|
||||
var ErrConfigRequired = errors.New("rest config is required")
|
||||
|
||||
func setDefaults(server *Server) error {
|
||||
if server.RestConfig == nil {
|
||||
if server.RESTConfig == nil {
|
||||
return ErrConfigRequired
|
||||
}
|
||||
|
||||
if server.Controllers == nil {
|
||||
var err error
|
||||
server.Controllers, err = NewController(server.RestConfig, nil)
|
||||
server.Controllers, err = NewController(server.RESTConfig, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func setup(ctx context.Context, server *Server) (http.Handler, *schema.Collectio
|
||||
|
||||
cf := server.ClientFactory
|
||||
if cf == nil {
|
||||
cf, err = client.NewFactory(server.RestConfig, server.AuthMiddleware != nil)
|
||||
cf, err = client.NewFactory(server.RESTConfig, server.AuthMiddleware != nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -67,6 +67,7 @@ func setup(ctx context.Context, server *Server) (http.Handler, *schema.Collectio
|
||||
}
|
||||
|
||||
ccache := clustercache.NewClusterCache(ctx, cf.DynamicClient())
|
||||
server.ClusterCache = ccache
|
||||
|
||||
server.BaseSchemas, err = resources.DefaultSchemas(ctx, server.BaseSchemas, ccache, cf)
|
||||
if err != nil {
|
||||
@@ -81,7 +82,7 @@ func setup(ctx context.Context, server *Server) (http.Handler, *schema.Collectio
|
||||
|
||||
server.SchemaTemplates = append(server.SchemaTemplates, resources.DefaultSchemaTemplates(cf, summaryCache, asl, server.K8s.Discovery())...)
|
||||
|
||||
cols, err := common.NewDynamicColumns(server.RestConfig)
|
||||
cols, err := common.NewDynamicColumns(server.RESTConfig)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func setup(ctx context.Context, server *Server) (http.Handler, *schema.Collectio
|
||||
ccache,
|
||||
sf)
|
||||
|
||||
handler, err := handler.New(server.RestConfig, sf, server.AuthMiddleware, server.Next, server.Router)
|
||||
handler, err := handler.New(server.RESTConfig, sf, server.AuthMiddleware, server.Next, server.Router)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user