From 3edfdf9ae3dd90cfe4eac11af5af785e55bb0c5d Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 20 Mar 2018 14:14:07 -0700 Subject: [PATCH] Remove pivotmapper --- apis/project.cattle.io/v3/schema/schema.go | 6 --- mapper/resource.go | 52 ---------------------- 2 files changed, 58 deletions(-) delete mode 100644 mapper/resource.go diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 9caeae41..3cb299f7 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -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"}, ). diff --git a/mapper/resource.go b/mapper/resource.go deleted file mode 100644 index 2b0ee31c..00000000 --- a/mapper/resource.go +++ /dev/null @@ -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 -}