37 Star 403 Fork 75

GVPrancher/rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
store.go 1004 Bytes
Copy Edit Raw Blame History
Dan Ramich authored 2019-06-12 13:38 . goimport linting changes
package preference
import (
"strings"
"github.com/rancher/norman/store/transform"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rancher/pkg/api/store/userscope"
v1 "github.com/rancher/types/apis/core/v1"
client "github.com/rancher/types/client/management/v3"
)
const (
NamespaceID = client.PreferenceFieldNamespaceId
)
func NewStore(nsClient v1.NamespaceInterface, store types.Store) types.Store {
return userscope.NewStore(nsClient,
&transform.Store{
Store: store,
Transformer: transformer,
})
}
func transformer(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, opts *types.QueryOptions) (map[string]interface{}, error) {
if data == nil {
return nil, nil
}
ns := convert.ToString(data[NamespaceID])
id := convert.ToString(data[types.ResourceFieldID])
id = strings.TrimPrefix(id, ns+":")
data[client.PreferenceFieldName] = id
data[types.ResourceFieldID] = id
return data, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.13

Search