mirror of
https://github.com/rancher/types.git
synced 2025-09-08 16:39:00 +00:00
Remove pivotmapper
This commit is contained in:
@@ -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"},
|
||||
).
|
||||
|
@@ -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
|
||||
}
|
Reference in New Issue
Block a user