1
0
mirror of https://github.com/rancher/types.git synced 2025-06-29 06:56:50 +00:00
types/mapper/creator.go

35 lines
718 B
Go
Raw Normal View History

2017-12-28 16:52:40 +00:00
package mapper
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/mapper"
)
type Creator struct {
m types.Mapper
}
func (c *Creator) FromInternal(data map[string]interface{}) {
if c.m != nil {
c.m.FromInternal(data)
}
}
func (c *Creator) ToInternal(data map[string]interface{}) {
if c.m != nil {
c.m.ToInternal(data)
}
}
func (c *Creator) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
if schema.CanList() && schema.CanCreate() {
schema.ResourceFields["creatorId"] = types.Field{
2017-12-29 22:20:33 +00:00
Type: "reference[user]",
CodeName: "CreatorID",
2017-12-28 16:52:40 +00:00
}
c.m = &mapper.AnnotationField{Field: "creatorId"}
return c.m.ModifySchema(schema, schemas)
}
return nil
}