37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
schema.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 2019-06-12 13:38 . goimport linting changes
package principals
import (
"context"
"net/url"
"github.com/rancher/norman/types"
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
client "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))}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.9-alpha1

搜索帮助

0d507c66 1850385 C8b1a773 1850385