1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-16 07:18:28 +00:00

Initial commit

This commit is contained in:
Darren Shepherd
2019-08-04 10:41:32 -07:00
commit c0299c1506
2045 changed files with 724722 additions and 0 deletions

31
pkg/server/mapper.go Normal file
View File

@@ -0,0 +1,31 @@
package server
import (
"fmt"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/values"
)
func newDefaultMapper() types.Mapper {
return &defaultMapper{}
}
type defaultMapper struct {
types.EmptyMapper
}
func (d *defaultMapper) FromInternal(data map[string]interface{}) {
if _, ok := data["id"]; ok || data == nil {
return
}
name := values.GetValueN(data, "metadata", "name")
namespace := values.GetValueN(data, "metadata", "namespace")
if namespace == "" {
data["id"] = name
} else {
data["id"] = fmt.Sprintf("%s/%s", namespace, name)
}
}