Fetch the repository succeeded.
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。