1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-18 00:08:17 +00:00
This commit is contained in:
Darren Shepherd
2020-01-30 22:01:21 -07:00
parent 9184741c57
commit 19c6732de0
2380 changed files with 587 additions and 759101 deletions

View File

@@ -0,0 +1,37 @@
package schema
import (
"fmt"
"github.com/rancher/norman/v2/pkg/data"
"github.com/rancher/norman/v2/pkg/types"
)
func newDefaultMapper() types.Mapper {
return &defaultMapper{}
}
type defaultMapper struct {
types.EmptyMapper
}
func (d *defaultMapper) FromInternal(data data.Object) {
if data["kind"] != "" && data["apiVersion"] != "" {
if t, ok := data["type"]; ok && data != nil {
data["_type"] = t
}
}
if _, ok := data["id"]; ok || data == nil {
return
}
name := types.Name(data)
namespace := types.Namespace(data)
if namespace == "" {
data["id"] = name
} else {
data["id"] = fmt.Sprintf("%s/%s", namespace, name)
}
}