forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
56 lines (48 loc) · 2.26 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package server
import (
"context"
"net/http"
"github.com/rancher/norman/api/builtin"
"github.com/rancher/norman/pkg/subscribe"
rancherapi "github.com/rancher/rancher/pkg/api"
"github.com/rancher/rancher/pkg/api/controllers/catalog"
"github.com/rancher/rancher/pkg/api/controllers/dynamicschema"
"github.com/rancher/rancher/pkg/api/controllers/samlconfig"
"github.com/rancher/rancher/pkg/api/controllers/settings"
"github.com/rancher/rancher/pkg/api/controllers/usercontrollers"
whitelistproxyKontainerDriver "github.com/rancher/rancher/pkg/api/controllers/whitelistproxy/kontainerdriver"
whitelistproxyNodeDriver "github.com/rancher/rancher/pkg/api/controllers/whitelistproxy/nodedriver"
"github.com/rancher/rancher/pkg/api/server/managementstored"
"github.com/rancher/rancher/pkg/api/server/userstored"
"github.com/rancher/rancher/pkg/clustermanager"
clusterSchema "github.com/rancher/types/apis/cluster.cattle.io/v3/schema"
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
projectSchema "github.com/rancher/types/apis/project.cattle.io/v3/schema"
"github.com/rancher/types/config"
)
func New(ctx context.Context, scaledContext *config.ScaledContext, clusterManager *clustermanager.Manager,
k8sProxy http.Handler) (http.Handler, error) {
subscribe.Register(&builtin.Version, scaledContext.Schemas)
subscribe.Register(&managementSchema.Version, scaledContext.Schemas)
subscribe.Register(&clusterSchema.Version, scaledContext.Schemas)
subscribe.Register(&projectSchema.Version, scaledContext.Schemas)
if err := managementstored.Setup(ctx, scaledContext, clusterManager, k8sProxy); err != nil {
return nil, err
}
if err := userstored.Setup(ctx, scaledContext, clusterManager, k8sProxy); err != nil {
return nil, err
}
server, err := rancherapi.NewServer(scaledContext.Schemas)
if err != nil {
return nil, err
}
server.AccessControl = scaledContext.AccessControl
catalog.Register(ctx, scaledContext)
dynamicschema.Register(ctx, scaledContext, server.Schemas)
whitelistproxyNodeDriver.Register(ctx, scaledContext)
whitelistproxyKontainerDriver.Register(ctx, scaledContext)
samlconfig.Register(ctx, scaledContext)
usercontrollers.Register(ctx, scaledContext, clusterManager)
err = settings.Register(scaledContext)
return server, err
}