37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
handler.go 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-02-20 12:54 . Add HA support and cluster import
package publicapi
import (
"context"
"net/http"
normanapi "github.com/rancher/norman/api"
"github.com/rancher/norman/store/subtype"
"github.com/rancher/norman/types"
publicSchema "github.com/rancher/types/apis/management.cattle.io/v3public/schema"
v3public "github.com/rancher/types/client/management/v3public"
"github.com/rancher/types/config"
)
func NewHandler(ctx context.Context, mgmtCtx *config.ScaledContext) (http.Handler, error) {
schemas := types.NewSchemas().AddSchemas(publicSchema.PublicSchemas)
if err := authProviderSchemas(ctx, mgmtCtx, schemas); err != nil {
return nil, err
}
server := normanapi.NewAPIServer()
if err := server.AddSchemas(schemas); err != nil {
return nil, err
}
return server, nil
}
var authProviderTypes = []string{v3public.LocalProviderType, v3public.GithubProviderType, v3public.ActiveDirectoryProviderType}
func authProviderSchemas(ctx context.Context, management *config.ScaledContext, schemas *types.Schemas) error {
schema := schemas.Schema(&publicSchema.PublicVersion, v3public.AuthProviderType)
setAuthProvidersStore(schema, management)
lh := newLoginHandler(management)
for _, apSubtype := range authProviderTypes {
subSchema := schemas.Schema(&publicSchema.PublicVersion, apSubtype)
subSchema.Store = subtype.NewSubTypeStore(apSubtype, schema.Store)
subSchema.ActionHandler = lh.login
subSchema.Formatter = loginActionFormatter
}
return nil
}
func loginActionFormatter(apiContext *types.APIContext, resource *types.RawResource) {
resource.AddAction(apiContext, "login")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-alpha17

搜索帮助