37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
schema.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
package principals
import (
"context"
"net/url"
"github.com/rancher/norman/types"
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
"github.com/rancher/types/client/management/v3"
"github.com/rancher/types/config"
)
func Schema(ctx context.Context, management *config.ScaledContext, schemas *types.Schemas) error {
p := newPrincipalsHandler(ctx, management)
schema := schemas.Schema(&managementSchema.Version, client.PrincipalType)
schema.ActionHandler = p.actions
schema.ListHandler = p.list
schema.CollectionFormatter = collectionFormatter
schema.Formatter = formatter
return nil
}
func collectionFormatter(apiContext *types.APIContext, collection *types.GenericCollection) {
collection.AddAction(apiContext, "search")
}
func formatter(request *types.APIContext, resource *types.RawResource) {
schema := request.Schemas.Schema(&managementSchema.Version, client.PrincipalType)
resource.Links = map[string]string{"self": request.URLBuilder.ResourceLinkByID(schema, url.PathEscape(resource.ID))}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.12-rc7

搜索帮助