Don't set type in mapper but instead the store

This commit is contained in:
Darren Shepherd
2019-08-13 16:35:47 -07:00
parent ecc80ef1e1
commit 0baa096865
5 changed files with 10 additions and 16 deletions

1
go.mod
View File

@@ -8,7 +8,6 @@ replace (
) )
require ( require (
github.com/googleapis/gnostic v0.2.0
github.com/gorilla/mux v1.7.3 github.com/gorilla/mux v1.7.3
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/rancher/norman v0.0.0-20190704000224-043a1c919df3 github.com/rancher/norman v0.0.0-20190704000224-043a1c919df3

View File

@@ -105,7 +105,7 @@ func Parse(apiOp *types.APIRequest, urlParser URLParser) error {
return err return err
} }
if apiOp.Schema == nil { if apiOp.Schema == nil && apiOp.Schemas != nil {
apiOp.Schema = apiOp.Schemas.Schema(apiOp.Type) apiOp.Schema = apiOp.Schemas.Schema(apiOp.Type)
} }

View File

@@ -319,5 +319,6 @@ func (s *Store) fromInternal(apiOp *types.APIRequest, schema *types.Schema, data
schema.Mapper.FromInternal(data) schema.Mapper.FromInternal(data)
} }
data["type"] = schema.ID
return data return data
} }

View File

@@ -90,12 +90,6 @@ func (t *typeMapper) FromInternal(data map[string]interface{}) {
} }
} }
if t.root {
if _, ok := data["type"]; !ok {
data["type"] = t.typeName
}
}
Mappers(t.Mappers).FromInternal(data) Mappers(t.Mappers).FromInternal(data)
} }

16
vendor/modules.txt vendored
View File

@@ -43,21 +43,21 @@ github.com/rancher/norman/pkg/authorization
github.com/rancher/norman/pkg/types github.com/rancher/norman/pkg/types
github.com/rancher/norman/pkg/types/convert github.com/rancher/norman/pkg/types/convert
github.com/rancher/norman/pkg/store/empty github.com/rancher/norman/pkg/store/empty
github.com/rancher/norman/pkg/store/proxy
github.com/rancher/norman/pkg/subscribe
github.com/rancher/norman/pkg/types/values github.com/rancher/norman/pkg/types/values
github.com/rancher/norman/pkg/api/builtin github.com/rancher/norman/pkg/api/builtin
github.com/rancher/norman/pkg/store/proxy
github.com/rancher/norman/pkg/api github.com/rancher/norman/pkg/api
github.com/rancher/norman/pkg/subscribe
github.com/rancher/norman/pkg/urlbuilder github.com/rancher/norman/pkg/urlbuilder
github.com/rancher/norman/pkg/httperror github.com/rancher/norman/pkg/httperror
github.com/rancher/norman/pkg/types/slice github.com/rancher/norman/pkg/types/slice
github.com/rancher/norman/pkg/data github.com/rancher/norman/pkg/data
github.com/rancher/norman/pkg/types/definition github.com/rancher/norman/pkg/types/definition
github.com/rancher/norman/pkg/store/schema
github.com/rancher/norman/pkg/types/convert/merge github.com/rancher/norman/pkg/types/convert/merge
github.com/rancher/norman/pkg/api/writer
github.com/rancher/norman/pkg/store/schema
github.com/rancher/norman/pkg/api/access github.com/rancher/norman/pkg/api/access
github.com/rancher/norman/pkg/api/handler github.com/rancher/norman/pkg/api/handler
github.com/rancher/norman/pkg/api/writer
github.com/rancher/norman/pkg/httperror/handler github.com/rancher/norman/pkg/httperror/handler
github.com/rancher/norman/pkg/parse github.com/rancher/norman/pkg/parse
github.com/rancher/norman/pkg/parse/builder github.com/rancher/norman/pkg/parse/builder
@@ -193,10 +193,10 @@ k8s.io/apimachinery/pkg/runtime/serializer/streaming
k8s.io/apimachinery/pkg/runtime/serializer/versioning k8s.io/apimachinery/pkg/runtime/serializer/versioning
k8s.io/apimachinery/pkg/api/errors k8s.io/apimachinery/pkg/api/errors
k8s.io/apimachinery/pkg/util/sets k8s.io/apimachinery/pkg/util/sets
k8s.io/apimachinery/pkg/util/httpstream
k8s.io/apimachinery/third_party/forked/golang/netutil
k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/json
k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/version
k8s.io/apimachinery/pkg/util/httpstream
k8s.io/apimachinery/third_party/forked/golang/netutil
k8s.io/apimachinery/pkg/api/validation/path k8s.io/apimachinery/pkg/api/validation/path
k8s.io/apimachinery/pkg/apis/meta/internalversion k8s.io/apimachinery/pkg/apis/meta/internalversion
k8s.io/apimachinery/pkg/util/wait k8s.io/apimachinery/pkg/util/wait
@@ -221,8 +221,8 @@ k8s.io/apiserver/pkg/apis/audit
# k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible # k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/client-go/dynamic k8s.io/client-go/dynamic
k8s.io/client-go/rest k8s.io/client-go/rest
k8s.io/client-go/transport
k8s.io/client-go/discovery k8s.io/client-go/discovery
k8s.io/client-go/transport
k8s.io/client-go/kubernetes k8s.io/client-go/kubernetes
k8s.io/client-go/informers/rbac/v1 k8s.io/client-go/informers/rbac/v1
k8s.io/client-go/kubernetes/typed/rbac/v1 k8s.io/client-go/kubernetes/typed/rbac/v1
@@ -235,8 +235,8 @@ k8s.io/client-go/tools/clientcmd/api
k8s.io/client-go/tools/metrics k8s.io/client-go/tools/metrics
k8s.io/client-go/util/cert k8s.io/client-go/util/cert
k8s.io/client-go/util/flowcontrol k8s.io/client-go/util/flowcontrol
k8s.io/client-go/tools/clientcmd
k8s.io/client-go/kubernetes/scheme k8s.io/client-go/kubernetes/scheme
k8s.io/client-go/tools/clientcmd
k8s.io/client-go/informers k8s.io/client-go/informers
k8s.io/client-go/informers/rbac k8s.io/client-go/informers/rbac
k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1 k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1