1
0
mirror of https://github.com/rancher/types.git synced 2025-08-31 21:00:16 +00:00
Files
types/mapper/creator.go

35 lines
736 B
Go
Raw Normal View History

2017-12-28 09:52:40 -07: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 {
2018-01-16 18:06:32 -07:00
if schema.CanList(nil) && schema.CanCreate(nil) {
2017-12-28 09:52:40 -07:00
schema.ResourceFields["creatorId"] = types.Field{
2018-02-13 16:46:50 -07:00
Type: "reference[/v3/schemas/user]",
2017-12-29 15:20:33 -07:00
CodeName: "CreatorID",
2017-12-28 09:52:40 -07:00
}
c.m = &mapper.AnnotationField{Field: "creatorId"}
return c.m.ModifySchema(schema, schemas)
}
return nil
}