1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-17 23:59:36 +00:00

Add root mapper

This commit is contained in:
Darren Shepherd
2018-06-19 11:20:37 -07:00
parent 0decad85cb
commit 003c94dd27

31
types/mapper/root.go Normal file
View File

@@ -0,0 +1,31 @@
package mapper
import (
"github.com/rancher/norman/types"
)
type Root struct {
enabled bool
Mapper types.Mapper
}
func (m *Root) FromInternal(data map[string]interface{}) {
if m.enabled {
m.Mapper.FromInternal(data)
}
}
func (m *Root) ToInternal(data map[string]interface{}) error {
if m.enabled {
return m.Mapper.ToInternal(data)
}
return nil
}
func (m *Root) ModifySchema(s *types.Schema, schemas *types.Schemas) error {
if s.CanList(nil) == nil {
m.enabled = true
return m.Mapper.ModifySchema(s, schemas)
}
return nil
}