1
0
mirror of https://github.com/rancher/types.git synced 2025-09-08 16:39:00 +00:00

Remove pivotmapper

This commit is contained in:
Darren Shepherd
2018-03-20 14:14:07 -07:00
parent 8dd77d3a66
commit 3edfdf9ae3
2 changed files with 0 additions and 58 deletions

View File

@@ -451,9 +451,6 @@ func podTypes(schemas *types.Schemas) *types.Schemas {
&m.Embed{Field: "securityContext"},
&m.Drop{Field: "serviceAccount"},
).
AddMapperForType(&Version, v1.ResourceRequirements{},
mapper.PivotMapper{Plural: true},
).
AddMapperForType(&Version, v1.Pod{},
&m.AnnotationField{Field: "description"},
&m.AnnotationField{Field: "publicEndpoints", List: true},
@@ -640,9 +637,6 @@ func volumeTypes(schemas *types.Schemas) *types.Schemas {
Field: "kind",
},
).
AddMapperForType(&Version, v1.ResourceRequirements{},
mapper.PivotMapper{Plural: true},
).
AddMapperForType(&Version, v1.PersistentVolumeClaimVolumeSource{},
&m.Move{From: "claimName", To: "persistentVolumeClaimName"},
).

View File

@@ -1,52 +0,0 @@
package mapper
import (
"strings"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/values"
)
type PivotMapper struct {
Plural bool
}
func (r PivotMapper) FromInternal(data map[string]interface{}) {
for key, value := range data {
mapValue, ok := value.(map[string]interface{})
if !ok {
continue
}
for subKey, subValue := range mapValue {
if r.Plural {
values.PutValue(data, subValue, subKey, strings.TrimSuffix(key, "s"))
} else {
values.PutValue(data, subValue, subKey, key)
}
}
delete(data, key)
}
}
func (r PivotMapper) ToInternal(data map[string]interface{}) {
for key, value := range data {
mapValue, ok := value.(map[string]interface{})
if !ok {
continue
}
for subKey, subValue := range mapValue {
if r.Plural {
values.PutValue(data, subValue, subKey, key+"s")
} else {
values.PutValue(data, subValue, subKey, key)
}
}
delete(data, key)
}
}
func (r PivotMapper) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
return nil
}