mirror of
https://github.com/rancher/types.git
synced 2025-06-03 02:49:24 +00:00
40 lines
779 B
Go
40 lines
779 B
Go
|
package mapper
|
||
|
|
||
|
import (
|
||
|
"github.com/rancher/norman/types"
|
||
|
"github.com/rancher/norman/types/mapper"
|
||
|
)
|
||
|
|
||
|
type NamespaceIDMapper struct {
|
||
|
Move *mapper.Move
|
||
|
}
|
||
|
|
||
|
func (n *NamespaceIDMapper) FromInternal(data map[string]interface{}) {
|
||
|
if n.Move != nil {
|
||
|
n.Move.FromInternal(data)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (n *NamespaceIDMapper) ToInternal(data map[string]interface{}) {
|
||
|
if n.Move != nil {
|
||
|
n.Move.ToInternal(data)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (n *NamespaceIDMapper) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
|
||
|
field, ok := schema.ResourceFields["namespace"]
|
||
|
if !ok {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
field.Type = "reference[namespace]"
|
||
|
schema.ResourceFields["namespace"] = field
|
||
|
|
||
|
n.Move = &mapper.Move{
|
||
|
From: "namespace",
|
||
|
To: "namespaceId",
|
||
|
}
|
||
|
|
||
|
return n.Move.ModifySchema(schema, schemas)
|
||
|
}
|